!function(t,e,i){function n(t,e){return typeof t===e}function s(){var t,e,i,s,o,a,r;for(var l in E)if(E.hasOwnProperty(l)){if(t=[],e=E[l],e.name&&(t.push(e.name.toLowerCase()),e.options&&e.options.aliases&&e.options.aliases.length))for(i=0;i<e.options.aliases.length;i++)t.push(e.options.aliases[i].toLowerCase());for(s=n(e.fn,"function")?e.fn():e.fn,o=0;o<t.length;o++)a=t[o],r=a.split("."),1===r.length?L[r[0]]=s:(!L[r[0]]||L[r[0]]instanceof Boolean||(L[r[0]]=new Boolean(L[r[0]])),L[r[0]][r[1]]=s),y.push((s?"":"no-")+r.join("-"))}}function o(t){var e=w.className,i=L._config.classPrefix||"";if(C&&(e=e.baseVal),L._config.enableJSClass){var n=new RegExp("(^|\\s)"+i+"no-js(\\s|$)");e=e.replace(n,"$1"+i+"js$2")}L._config.enableClasses&&(e+=" "+i+t.join(" "+i),C?w.className.baseVal=e:w.className=e)}function a(){return"function"!=typeof e.createElement?e.createElement(arguments[0]):C?e.createElementNS.call(e,"http://www.w3.org/2000/svg",arguments[0]):e.createElement.apply(e,arguments)}function r(t,e){return!!~(""+t).indexOf(e)}function l(t){return t.replace(/([a-z])-([a-z])/g,function(t,e,i){return e+i.toUpperCase()}).replace(/^-/,"")}function d(){var t=e.body;return t||(t=a(C?"svg":"body"),t.fake=!0),t}function c(t,i,n,s){var o,r,l,c,h="modernizr",u=a("div"),p=d();if(parseInt(n,10))for(;n--;)l=a("div"),l.id=s?s[n]:h+(n+1),u.appendChild(l);return o=a("style"),o.type="text/css",o.id="s"+h,(p.fake?p:u).appendChild(o),p.appendChild(u),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(e.createTextNode(t)),u.id=h,p.fake&&(p.style.background="",p.style.overflow="hidden",c=w.style.overflow,w.style.overflow="hidden",w.appendChild(p)),r=i(u,t),p.fake?(p.parentNode.removeChild(p),w.style.overflow=c,w.offsetHeight):u.parentNode.removeChild(u),!!r}function h(t,e){if("object"==typeof t)for(var i in t)O(t,i)&&h(i,t[i]);else{t=t.toLowerCase();var n=t.split("."),s=L[n[0]];if(2==n.length&&(s=s[n[1]]),"undefined"!=typeof s)return L;e="function"==typeof e?e():e,1==n.length?L[n[0]]=e:(!L[n[0]]||L[n[0]]instanceof Boolean||(L[n[0]]=new Boolean(L[n[0]])),L[n[0]][n[1]]=e),o([(e&&0!=e?"":"no-")+n.join("-")]),L._trigger(t,e)}return L}function u(t,e){return function(){return t.apply(e,arguments)}}function p(t,e,i){var s;for(var o in t)if(t[o]in e)return i===!1?t[o]:(s=e[t[o]],n(s,"function")?u(s,i||e):s);return!1}function m(t){return t.replace(/([A-Z])/g,function(t,e){return"-"+e.toLowerCase()}).replace(/^ms-/,"-ms-")}function f(e,i,n){var s;if("getComputedStyle"in t){s=getComputedStyle.call(t,e,i);var o=t.console;if(null!==s)n&&(s=s.getPropertyValue(n));else if(o){var a=o.error?"error":"log";o[a].call(o,"getComputedStyle returning null, its possible modernizr test results are inaccurate")}}else s=!i&&e.currentStyle&&e.currentStyle[n];return s}function g(e,n){var s=e.length;if("CSS"in t&&"supports"in t.CSS){for(;s--;)if(t.CSS.supports(m(e[s]),n))return!0;return!1}if("CSSSupportsRule"in t){for(var o=[];s--;)o.push("("+m(e[s])+":"+n+")");return o=o.join(" or "),c("@supports ("+o+") { #modernizr { position: absolute; } }",function(t){return"absolute"==f(t,null,"position")})}return i}function v(t,e,s,o){function d(){h&&(delete N.style,delete N.modElem)}if(o=!n(o,"undefined")&&o,!n(s,"undefined")){var c=g(t,s);if(!n(c,"undefined"))return c}for(var h,u,p,m,f,v=["modernizr","tspan","samp"];!N.style&&v.length;)h=!0,N.modElem=a(v.shift()),N.style=N.modElem.style;for(p=t.length,u=0;u<p;u++)if(m=t[u],f=N.style[m],r(m,"-")&&(m=l(m)),N.style[m]!==i){if(o||n(s,"undefined"))return d(),"pfx"!=e||m;try{N.style[m]=s}catch(t){}if(N.style[m]!=f)return d(),"pfx"!=e||m}return d(),!1}function b(t,e,i,s,o){var a=t.charAt(0).toUpperCase()+t.slice(1),r=(t+" "+x.join(a+" ")+a).split(" ");return n(e,"string")||n(e,"undefined")?v(r,e,s,o):(r=(t+" "+D.join(a+" ")+a).split(" "),p(r,e,i))}function S(t,e,n){return b(t,i,i,e,n)}var y=[],E=[],T={_version:"3.5.0",_config:{classPrefix:"mz-",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(t,e){var i=this;setTimeout(function(){e(i[t])},0)},addTest:function(t,e,i){E.push({name:t,fn:e,options:i})},addAsyncTest:function(t){E.push({name:null,fn:t})}},L=function(){};L.prototype=T,L=new L,L.addTest("history",function(){var e=navigator.userAgent;return(e.indexOf("Android 2.")===-1&&e.indexOf("Android 4.0")===-1||e.indexOf("Mobile Safari")===-1||e.indexOf("Chrome")!==-1||e.indexOf("Windows Phone")!==-1||"file:"===location.protocol)&&(t.history&&"pushState"in t.history)}),L.addTest("svg",!!e.createElementNS&&!!e.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect),L.addTest("localstorage",function(){var t="modernizr";try{return localStorage.setItem(t,t),localStorage.removeItem(t),!0}catch(t){return!1}});var k=T._config.usePrefixes?" -webkit- -moz- -o- -ms- ".split(" "):["",""];T._prefixes=k;var w=e.documentElement,C="svg"===w.nodeName.toLowerCase(),_="Moz O ms Webkit",D=T._config.usePrefixes?_.toLowerCase().split(" "):[];T._domPrefixes=D,L.addTest("csspositionsticky",function(){var t="position:",e="sticky",i=a("a"),n=i.style;return n.cssText=t+k.join(e+";"+t).slice(0,-t.length),n.position.indexOf(e)!==-1});var A="CSS"in t&&"supports"in t.CSS,I="supportsCSS"in t;L.addTest("supports",A||I);var x=T._config.usePrefixes?_.split(" "):[];T._cssomPrefixes=x;var R=T.testStyles=c,M=function(e){var n,s=k.length,o=t.CSSRule;if("undefined"==typeof o)return i;if(!e)return!1;if(e=e.replace(/^@/,""),n=e.replace(/-/g,"_").toUpperCase()+"_RULE",n in o)return"@"+e;for(var a=0;a<s;a++){var r=k[a],l=r.toUpperCase()+"_"+n;if(l in o)return"@-"+r.toLowerCase()+"-"+e}return!1};T.atRule=M;var O;!function(){var t={}.hasOwnProperty;O=n(t,"undefined")||n(t.call,"undefined")?function(t,e){return e in t&&n(t.constructor.prototype[e],"undefined")}:function(e,i){return t.call(e,i)}}(),T._l={},T.on=function(t,e){this._l[t]||(this._l[t]=[]),this._l[t].push(e),L.hasOwnProperty(t)&&setTimeout(function(){L._trigger(t,L[t])},0)},T._trigger=function(t,e){if(this._l[t]){var i=this._l[t];setTimeout(function(){var t,n;for(t=0;t<i.length;t++)(n=i[t])(e)},0),delete this._l[t]}},L._q.push(function(){T.addTest=h}),L.addAsyncTest(function(){var t=new Image;t.onerror=function(){h("webpanimation",!1,{aliases:["webp-animation"]})},t.onload=function(){h("webpanimation",1==t.width,{aliases:["webp-animation"]})},t.src=""});var P={elem:a("modernizr")};L._q.push(function(){delete P.elem});var N={style:P.elem.style};L._q.unshift(function(){delete N.style});T.testProp=function(t,e,n){return v([t],i,e,n)};T.testAllProps=b,T.testAllProps=S,L.addTest("cssanimations",S("animationName","a",!0)),L.addTest("backgroundsize",S("backgroundSize","100%",!0)),L.addTest("cssgridlegacy",S("grid-columns","10px",!0)),L.addTest("cssgrid",S("grid-template-rows","none",!0)),L.addTest("flexbox",S("flexBasis","1px",!0)),L.addTest("csstransforms",function(){return navigator.userAgent.indexOf("Android 2.")===-1&&S("transform","scale(1)",!0)}),L.addTest("csstransforms3d",function(){var t=!!S("perspective","1px",!0),e=L._config.usePrefixes;if(t&&(!e||"webkitPerspective"in w.style)){var i,n="#modernizr{width:0;height:0}";L.supports?i="@supports (perspective: 1px)":(i="@media (transform-3d)",e&&(i+=",(-webkit-transform-3d)")),i+="{#modernizr{width:7px;height:18px;margin:0;padding:0;border:0}}",R(n+i,function(e){t=7===e.offsetWidth&&18===e.offsetHeight})}return t}),L.addTest("csstransitions",S("transition","all",!0));var $=T.prefixed=function(t,e,i){return 0===t.indexOf("@")?M(t):(t.indexOf("-")!=-1&&(t=l(t)),e?b(t,e,i):b(t,"pfx"))};L.addTest("fullscreen",!(!$("exitFullscreen",e,!1)&&!$("cancelFullScreen",e,!1))),s(),o(y),delete T.addTest,delete T.addAsyncTest;for(var U=0;U<L._q.length;U++)L._q[U]();t.Modernizr=L}(window,document),function(t,e){"object"==typeof module&&"object"==typeof module.exports?module.exports=t.document?e(t,!0):function(t){if(!t.document)throw new Error("jQuery requires a window with a document");return e(t)}:e(t)}("undefined"!=typeof window?window:this,function(t,e){function i(t){var e=!!t&&"length"in t&&t.length,i=pt.type(t);return"function"!==i&&!pt.isWindow(t)&&("array"===i||0===e||"number"==typeof e&&e>0&&e-1 in t)}function n(t,e,i){if(pt.isFunction(e))return pt.grep(t,function(t,n){return!!e.call(t,n,t)!==i});if(e.nodeType)return pt.grep(t,function(t){return t===e!==i});if("string"==typeof e){if(Lt.test(e))return pt.filter(e,t,i);e=pt.filter(e,t)}return pt.grep(t,function(t){return pt.inArray(t,e)>-1!==i})}function s(t,e){do t=t[e];while(t&&1!==t.nodeType);return t}function o(t){var e={};return pt.each(t.match(At)||[],function(t,i){e[i]=!0}),e}function a(){nt.addEventListener?(nt.removeEventListener("DOMContentLoaded",r),t.removeEventListener("load",r)):(nt.detachEvent("onreadystatechange",r),t.detachEvent("onload",r))}function r(){(nt.addEventListener||"load"===t.event.type||"complete"===nt.readyState)&&(a(),pt.ready())}function l(t,e,i){if(void 0===i&&1===t.nodeType){var n="data-"+e.replace(Ot,"-$1").toLowerCase();if(i=t.getAttribute(n),"string"==typeof i){try{i="true"===i||"false"!==i&&("null"===i?null:+i+""===i?+i:Mt.test(i)?pt.parseJSON(i):i)}catch(t){}pt.data(t,e,i)}else i=void 0}return i}function d(t){var e;for(e in t)if(("data"!==e||!pt.isEmptyObject(t[e]))&&"toJSON"!==e)return!1;return!0}function c(t,e,i,n){if(Rt(t)){var s,o,a=pt.expando,r=t.nodeType,l=r?pt.cache:t,d=r?t[a]:t[a]&&a;if(d&&l[d]&&(n||l[d].data)||void 0!==i||"string"!=typeof e)return d||(d=r?t[a]=it.pop()||pt.guid++:a),l[d]||(l[d]=r?{}:{toJSON:pt.noop}),"object"!=typeof e&&"function"!=typeof e||(n?l[d]=pt.extend(l[d],e):l[d].data=pt.extend(l[d].data,e)),o=l[d],n||(o.data||(o.data={}),o=o.data),void 0!==i&&(o[pt.camelCase(e)]=i),"string"==typeof e?(s=o[e],null==s&&(s=o[pt.camelCase(e)])):s=o,s}}function h(t,e,i){if(Rt(t)){var n,s,o=t.nodeType,a=o?pt.cache:t,r=o?t[pt.expando]:pt.expando;if(a[r]){if(e&&(n=i?a[r]:a[r].data)){pt.isArray(e)?e=e.concat(pt.map(e,pt.camelCase)):e in n?e=[e]:(e=pt.camelCase(e),e=e in n?[e]:e.split(" ")),s=e.length;for(;s--;)delete n[e[s]];if(i?!d(n):!pt.isEmptyObject(n))return}(i||(delete a[r].data,d(a[r])))&&(o?pt.cleanData([t],!0):ht.deleteExpando||a!=a.window?delete a[r]:a[r]=void 0)}}}function u(t,e,i,n){var s,o=1,a=20,r=n?function(){return n.cur()}:function(){return pt.css(t,e,"")},l=r(),d=i&&i[3]||(pt.cssNumber[e]?"":"px"),c=(pt.cssNumber[e]||"px"!==d&&+l)&&Nt.exec(pt.css(t,e));if(c&&c[3]!==d){d=d||c[3],i=i||[],c=+l||1;do o=o||".5",c/=o,pt.style(t,e,c+d);while(o!==(o=r()/l)&&1!==o&&--a)}return i&&(c=+c||+l||0,s=i[1]?c+(i[1]+1)*i[2]:+i[2],n&&(n.unit=d,n.start=c,n.end=s)),s}function p(t){var e=zt.split("|"),i=t.createDocumentFragment();if(i.createElement)for(;e.length;)i.createElement(e.pop());return i}function m(t,e){var i,n,s=0,o="undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e||"*"):"undefined"!=typeof t.querySelectorAll?t.querySelectorAll(e||"*"):void 0;if(!o)for(o=[],i=t.childNodes||t;null!=(n=i[s]);s++)!e||pt.nodeName(n,e)?o.push(n):pt.merge(o,m(n,e));return void 0===e||e&&pt.nodeName(t,e)?pt.merge([t],o):o}function f(t,e){for(var i,n=0;null!=(i=t[n]);n++)pt._data(i,"globalEval",!e||pt._data(e[n],"globalEval"))}function g(t){Bt.test(t.type)&&(t.defaultChecked=t.checked)}function v(t,e,i,n,s){for(var o,a,r,l,d,c,h,u=t.length,v=p(e),b=[],S=0;S<u;S++)if(a=t[S],a||0===a)if("object"===pt.type(a))pt.merge(b,a.nodeType?[a]:a);else if(Wt.test(a)){for(l=l||v.appendChild(e.createElement("div")),d=(Ht.exec(a)||["",""])[1].toLowerCase(),h=Gt[d]||Gt._default,l.innerHTML=h[1]+pt.htmlPrefilter(a)+h[2],o=h[0];o--;)l=l.lastChild;if(!ht.leadingWhitespace&&Vt.test(a)&&b.push(e.createTextNode(Vt.exec(a)[0])),!ht.tbody)for(a="table"!==d||Kt.test(a)?"<table>"!==h[1]||Kt.test(a)?0:l:l.firstChild,o=a&&a.childNodes.length;o--;)pt.nodeName(c=a.childNodes[o],"tbody")&&!c.childNodes.length&&a.removeChild(c);for(pt.merge(b,l.childNodes),l.textContent="";l.firstChild;)l.removeChild(l.firstChild);l=v.lastChild}else b.push(e.createTextNode(a));for(l&&v.removeChild(l),ht.appendChecked||pt.grep(m(b,"input"),g),S=0;a=b[S++];)if(n&&pt.inArray(a,n)>-1)s&&s.push(a);else if(r=pt.contains(a.ownerDocument,a),l=m(v.appendChild(a),"script"),r&&f(l),i)for(o=0;a=l[o++];)jt.test(a.type||"")&&i.push(a);return l=null,v}function b(){return!0}function S(){return!1}function y(){try{return nt.activeElement}catch(t){}}function E(t,e,i,n,s,o){var a,r;if("object"==typeof e){"string"!=typeof i&&(n=n||i,i=void 0);for(r in e)E(t,r,i,n,e[r],o);return t}if(null==n&&null==s?(s=i,n=i=void 0):null==s&&("string"==typeof i?(s=n,n=void 0):(s=n,n=i,i=void 0)),s===!1)s=S;else if(!s)return t;return 1===o&&(a=s,s=function(t){return pt().off(t),a.apply(this,arguments)},s.guid=a.guid||(a.guid=pt.guid++)),t.each(function(){pt.event.add(this,e,s,n,i)})}function T(t,e){return pt.nodeName(t,"table")&&pt.nodeName(11!==e.nodeType?e:e.firstChild,"tr")?t.getElementsByTagName("tbody")[0]||t.appendChild(t.ownerDocument.createElement("tbody")):t}function L(t){return t.type=(null!==pt.find.attr(t,"type"))+"/"+t.type,t}function k(t){var e=se.exec(t.type);return e?t.type=e[1]:t.removeAttribute("type"),t}function w(t,e){if(1===e.nodeType&&pt.hasData(t)){var i,n,s,o=pt._data(t),a=pt._data(e,o),r=o.events;if(r){delete a.handle,a.events={};for(i in r)for(n=0,s=r[i].length;n<s;n++)pt.event.add(e,i,r[i][n])}a.data&&(a.data=pt.extend({},a.data))}}function C(t,e){var i,n,s;if(1===e.nodeType){if(i=e.nodeName.toLowerCase(),!ht.noCloneEvent&&e[pt.expando]){s=pt._data(e);for(n in s.events)pt.removeEvent(e,n,s.handle);e.removeAttribute(pt.expando)}"script"===i&&e.text!==t.text?(L(e).text=t.text,k(e)):"object"===i?(e.parentNode&&(e.outerHTML=t.outerHTML),ht.html5Clone&&t.innerHTML&&!pt.trim(e.innerHTML)&&(e.innerHTML=t.innerHTML)):"input"===i&&Bt.test(t.type)?(e.defaultChecked=e.checked=t.checked,e.value!==t.value&&(e.value=t.value)):"option"===i?e.defaultSelected=e.selected=t.defaultSelected:"input"!==i&&"textarea"!==i||(e.defaultValue=t.defaultValue)}}function _(t,e,i,n){e=ot.apply([],e);var s,o,a,r,l,d,c=0,h=t.length,u=h-1,p=e[0],f=pt.isFunction(p);if(f||h>1&&"string"==typeof p&&!ht.checkClone&&ne.test(p))return t.each(function(s){var o=t.eq(s);f&&(e[0]=p.call(this,s,o.html())),_(o,e,i,n)});if(h&&(d=v(e,t[0].ownerDocument,!1,t,n),s=d.firstChild,1===d.childNodes.length&&(d=s),s||n)){for(r=pt.map(m(d,"script"),L),a=r.length;c<h;c++)o=d,c!==u&&(o=pt.clone(o,!0,!0),a&&pt.merge(r,m(o,"script"))),i.call(t[c],o,c);if(a)for(l=r[r.length-1].ownerDocument,pt.map(r,k),c=0;c<a;c++)o=r[c],jt.test(o.type||"")&&!pt._data(o,"globalEval")&&pt.contains(l,o)&&(o.src?pt._evalUrl&&pt._evalUrl(o.src):pt.globalEval((o.text||o.textContent||o.innerHTML||"").replace(oe,"")));d=s=null}return t}function D(t,e,i){for(var n,s=e?pt.filter(e,t):t,o=0;null!=(n=s[o]);o++)i||1!==n.nodeType||pt.cleanData(m(n)),n.parentNode&&(i&&pt.contains(n.ownerDocument,n)&&f(m(n,"script")),n.parentNode.removeChild(n));return t}function A(t,e){var i=pt(e.createElement(t)).appendTo(e.body),n=pt.css(i[0],"display");return i.detach(),n}function I(t){var e=nt,i=de[t];return i||(i=A(t,e),"none"!==i&&i||(le=(le||pt("<iframe frameborder='0' width='0' height='0'/>")).appendTo(e.documentElement),e=(le[0].contentWindow||le[0].contentDocument).document,e.write(),e.close(),i=A(t,e),le.detach()),de[t]=i),i}function x(t,e){return{get:function(){return t()?void delete this.get:(this.get=e).apply(this,arguments)}}}function R(t){if(t in ke)return t;for(var e=t.charAt(0).toUpperCase()+t.slice(1),i=Le.length;i--;)if(t=Le[i]+e,t in ke)return t}function M(t,e){for(var i,n,s,o=[],a=0,r=t.length;a<r;a++)n=t[a],n.style&&(o[a]=pt._data(n,"olddisplay"),i=n.style.display,e?(o[a]||"none"!==i||(n.style.display=""),""===n.style.display&&Ut(n)&&(o[a]=pt._data(n,"olddisplay",I(n.nodeName)))):(s=Ut(n),(i&&"none"!==i||!s)&&pt._data(n,"olddisplay",s?i:pt.css(n,"display"))));for(a=0;a<r;a++)n=t[a],n.style&&(e&&"none"!==n.style.display&&""!==n.style.display||(n.style.display=e?o[a]||"":"none"));return t}function O(t,e,i){var n=ye.exec(e);return n?Math.max(0,n[1]-(i||0))+(n[2]||"px"):e}function P(t,e,i,n,s){for(var o=i===(n?"border":"content")?4:"width"===e?1:0,a=0;o<4;o+=2)"margin"===i&&(a+=pt.css(t,i+$t[o],!0,s)),n?("content"===i&&(a-=pt.css(t,"padding"+$t[o],!0,s)),"margin"!==i&&(a-=pt.css(t,"border"+$t[o]+"Width",!0,s))):(a+=pt.css(t,"padding"+$t[o],!0,s),"padding"!==i&&(a+=pt.css(t,"border"+$t[o]+"Width",!0,s)));return a}function N(t,e,i){var n=!0,s="width"===e?t.offsetWidth:t.offsetHeight,o=me(t),a=ht.boxSizing&&"border-box"===pt.css(t,"boxSizing",!1,o);if(s<=0||null==s){if(s=fe(t,e,o),(s<0||null==s)&&(s=t.style[e]),he.test(s))return s;n=a&&(ht.boxSizingReliable()||s===t.style[e]),s=parseFloat(s)||0}return s+P(t,e,i||(a?"border":"content"),n,o)+"px"}function $(t,e,i,n,s){return new $.prototype.init(t,e,i,n,s)}function U(){return t.setTimeout(function(){we=void 0}),we=pt.now()}function F(t,e){var i,n={height:t},s=0;for(e=e?1:0;s<4;s+=2-e)i=$t[s],n["margin"+i]=n["padding"+i]=t;return e&&(n.opacity=n.width=t),n}function B(t,e,i){for(var n,s=(V.tweeners[e]||[]).concat(V.tweeners["*"]),o=0,a=s.length;o<a;o++)if(n=s[o].call(i,e,t))return n}function H(t,e,i){var n,s,o,a,r,l,d,c,h=this,u={},p=t.style,m=t.nodeType&&Ut(t),f=pt._data(t,"fxshow");i.queue||(r=pt._queueHooks(t,"fx"),null==r.unqueued&&(r.unqueued=0,l=r.empty.fire,r.empty.fire=function(){r.unqueued||l()}),r.unqueued++,h.always(function(){h.always(function(){r.unqueued--,pt.queue(t,"fx").length||r.empty.fire()})})),1===t.nodeType&&("height"in e||"width"in e)&&(i.overflow=[p.overflow,p.overflowX,p.overflowY],d=pt.css(t,"display"),c="none"===d?pt._data(t,"olddisplay")||I(t.nodeName):d,"inline"===c&&"none"===pt.css(t,"float")&&(ht.inlineBlockNeedsLayout&&"inline"!==I(t.nodeName)?p.zoom=1:p.display="inline-block")),i.overflow&&(p.overflow="hidden",ht.shrinkWrapBlocks()||h.always(function(){p.overflow=i.overflow[0],p.overflowX=i.overflow[1],p.overflowY=i.overflow[2]}));for(n in e)if(s=e[n],_e.exec(s)){if(delete e[n],o=o||"toggle"===s,s===(m?"hide":"show")){if("show"!==s||!f||void 0===f[n])continue;m=!0}u[n]=f&&f[n]||pt.style(t,n)}else d=void 0;if(pt.isEmptyObject(u))"inline"===("none"===d?I(t.nodeName):d)&&(p.display=d);else{f?"hidden"in f&&(m=f.hidden):f=pt._data(t,"fxshow",{}),o&&(f.hidden=!m),m?pt(t).show():h.done(function(){pt(t).hide()}),h.done(function(){var e;pt._removeData(t,"fxshow");for(e in u)pt.style(t,e,u[e])});for(n in u)a=B(m?f[n]:0,n,h),n in f||(f[n]=a.start,m&&(a.end=a.start,a.start="width"===n||"height"===n?1:0))}}function j(t,e){var i,n,s,o,a;for(i in t)if(n=pt.camelCase(i),s=e[n],o=t[i],pt.isArray(o)&&(s=o[1],o=t[i]=o[0]),i!==n&&(t[n]=o,delete t[i]),a=pt.cssHooks[n],a&&"expand"in a){o=a.expand(o),delete t[n];for(i in o)i in t||(t[i]=o[i],e[i]=s)}else e[n]=s}function V(t,e,i){var n,s,o=0,a=V.prefilters.length,r=pt.Deferred().always(function(){delete l.elem}),l=function(){if(s)return!1;for(var e=we||U(),i=Math.max(0,d.startTime+d.duration-e),n=i/d.duration||0,o=1-n,a=0,l=d.tweens.length;a<l;a++)d.tweens[a].run(o);return r.notifyWith(t,[d,o,i]),o<1&&l?i:(r.resolveWith(t,[d]),!1)},d=r.promise({elem:t,props:pt.extend({},e),opts:pt.extend(!0,{specialEasing:{},easing:pt.easing._default},i),originalProperties:e,originalOptions:i,startTime:we||U(),duration:i.duration,tweens:[],createTween:function(e,i){var n=pt.Tween(t,d.opts,e,i,d.opts.specialEasing[e]||d.opts.easing);return d.tweens.push(n),n},stop:function(e){var i=0,n=e?d.tweens.length:0;if(s)return this;for(s=!0;i<n;i++)d.tweens[i].run(1);return e?(r.notifyWith(t,[d,1,0]),r.resolveWith(t,[d,e])):r.rejectWith(t,[d,e]),this}}),c=d.props;for(j(c,d.opts.specialEasing);o<a;o++)if(n=V.prefilters[o].call(d,t,c,d.opts))return pt.isFunction(n.stop)&&(pt._queueHooks(d.elem,d.opts.queue).stop=pt.proxy(n.stop,n)),n;return pt.map(c,B,d),pt.isFunction(d.opts.start)&&d.opts.start.call(t,d),pt.fx.timer(pt.extend(l,{elem:t,anim:d,queue:d.opts.queue})),d.progress(d.opts.progress).done(d.opts.done,d.opts.complete).fail(d.opts.fail).always(d.opts.always)}function z(t){return pt.attr(t,"class")||""}function G(t){return function(e,i){"string"!=typeof e&&(i=e,e="*");var n,s=0,o=e.toLowerCase().match(At)||[];if(pt.isFunction(i))for(;n=o[s++];)"+"===n.charAt(0)?(n=n.slice(1)||"*",(t[n]=t[n]||[]).unshift(i)):(t[n]=t[n]||[]).push(i)}}function W(t,e,i,n){function s(r){var l;return o[r]=!0,pt.each(t[r]||[],function(t,r){var d=r(e,i,n);return"string"!=typeof d||a||o[d]?a?!(l=d):void 0:(e.dataTypes.unshift(d),s(d),!1)}),l}var o={},a=t===Qe;return s(e.dataTypes[0])||!o["*"]&&s("*")}function K(t,e){var i,n,s=pt.ajaxSettings.flatOptions||{};for(n in e)void 0!==e[n]&&((s[n]?t:i||(i={}))[n]=e[n]);return i&&pt.extend(!0,t,i),t}function Y(t,e,i){for(var n,s,o,a,r=t.contents,l=t.dataTypes;"*"===l[0];)l.shift(),void 0===s&&(s=t.mimeType||e.getResponseHeader("Content-Type"));if(s)for(a in r)if(r[a]&&r[a].test(s)){l.unshift(a);break}if(l[0]in i)o=l[0];else{for(a in i){if(!l[0]||t.converters[a+" "+l[0]]){o=a;break}n||(n=a)}o=o||n}if(o)return o!==l[0]&&l.unshift(o),i[o]}function q(t,e,i,n){var s,o,a,r,l,d={},c=t.dataTypes.slice();if(c[1])for(a in t.converters)d[a.toLowerCase()]=t.converters[a];for(o=c.shift();o;)if(t.responseFields[o]&&(i[t.responseFields[o]]=e),!l&&n&&t.dataFilter&&(e=t.dataFilter(e,t.dataType)),l=o,o=c.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(a=d[l+" "+o]||d["* "+o],!a)for(s in d)if(r=s.split(" "),r[1]===o&&(a=d[l+" "+r[0]]||d["* "+r[0]])){a===!0?a=d[s]:d[s]!==!0&&(o=r[0],c.unshift(r[1]));break}if(a!==!0)if(a&&t["throws"])e=a(e);else try{e=a(e)}catch(t){return{state:"parsererror",error:a?t:"No conversion from "+l+" to "+o}}}return{state:"success",data:e}}function X(t){return t.style&&t.style.display||pt.css(t,"display")}function J(t){if(!pt.contains(t.ownerDocument||nt,t))return!0;for(;t&&1===t.nodeType;){if("none"===X(t)||"hidden"===t.type)return!0;t=t.parentNode}return!1}function Q(t,e,i,n){var s;if(pt.isArray(e))pt.each(e,function(e,s){i||ni.test(t)?n(t,s):Q(t+"["+("object"==typeof s&&null!=s?e:"")+"]",s,i,n)});else if(i||"object"!==pt.type(e))n(t,e);else for(s in e)Q(t+"["+s+"]",e[s],i,n)}function Z(){try{return new t.XMLHttpRequest}catch(t){}}function tt(){try{return new t.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}function et(t){return pt.isWindow(t)?t:9===t.nodeType&&(t.defaultView||t.parentWindow)}var it=[],nt=t.document,st=it.slice,ot=it.concat,at=it.push,rt=it.indexOf,lt={},dt=lt.toString,ct=lt.hasOwnProperty,ht={},ut="1.12.4",pt=function(t,e){return new pt.fn.init(t,e)},mt=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,ft=/^-ms-/,gt=/-([\da-z])/gi,vt=function(t,e){return e.toUpperCase()};pt.fn=pt.prototype={jquery:ut,constructor:pt,selector:"",length:0,toArray:function(){return st.call(this)},get:function(t){return null!=t?t<0?this[t+this.length]:this[t]:st.call(this)},pushStack:function(t){var e=pt.merge(this.constructor(),t);return e.prevObject=this,e.context=this.context,e},each:function(t){return pt.each(this,t)},map:function(t){return this.pushStack(pt.map(this,function(e,i){return t.call(e,i,e)}))},slice:function(){return this.pushStack(st.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(t){var e=this.length,i=+t+(t<0?e:0);return this.pushStack(i>=0&&i<e?[this[i]]:[])},end:function(){return this.prevObject||this.constructor()},push:at,sort:it.sort,splice:it.splice},pt.extend=pt.fn.extend=function(){var t,e,i,n,s,o,a=arguments[0]||{},r=1,l=arguments.length,d=!1;for("boolean"==typeof a&&(d=a,a=arguments[r]||{},r++),"object"==typeof a||pt.isFunction(a)||(a={}),r===l&&(a=this,r--);r<l;r++)if(null!=(s=arguments[r]))for(n in s)t=a[n],i=s[n],a!==i&&(d&&i&&(pt.isPlainObject(i)||(e=pt.isArray(i)))?(e?(e=!1,o=t&&pt.isArray(t)?t:[]):o=t&&pt.isPlainObject(t)?t:{},a[n]=pt.extend(d,o,i)):void 0!==i&&(a[n]=i));return a},pt.extend({expando:"jQuery"+(ut+Math.random()).replace(/\D/g,""),isReady:!0,error:function(t){throw new Error(t)},noop:function(){},isFunction:function(t){return"function"===pt.type(t)},isArray:Array.isArray||function(t){return"array"===pt.type(t)},isWindow:function(t){return null!=t&&t==t.window},isNumeric:function(t){var e=t&&t.toString();return!pt.isArray(t)&&e-parseFloat(e)+1>=0},isEmptyObject:function(t){var e;for(e in t)return!1;return!0},isPlainObject:function(t){var e;if(!t||"object"!==pt.type(t)||t.nodeType||pt.isWindow(t))return!1;try{if(t.constructor&&!ct.call(t,"constructor")&&!ct.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}if(!ht.ownFirst)for(e in t)return ct.call(t,e);for(e in t);return void 0===e||ct.call(t,e)},type:function(t){return null==t?t+"":"object"==typeof t||"function"==typeof t?lt[dt.call(t)]||"object":typeof t},globalEval:function(e){e&&pt.trim(e)&&(t.execScript||function(e){t.eval.call(t,e)})(e)},camelCase:function(t){return t.replace(ft,"ms-").replace(gt,vt)},nodeName:function(t,e){return t.nodeName&&t.nodeName.toLowerCase()===e.toLowerCase()},each:function(t,e){var n,s=0;if(i(t))for(n=t.length;s<n&&e.call(t[s],s,t[s])!==!1;s++);else for(s in t)if(e.call(t[s],s,t[s])===!1)break;return t},trim:function(t){return null==t?"":(t+"").replace(mt,"")},makeArray:function(t,e){var n=e||[];return null!=t&&(i(Object(t))?pt.merge(n,"string"==typeof t?[t]:t):at.call(n,t)),n},inArray:function(t,e,i){var n;if(e){if(rt)return rt.call(e,t,i);for(n=e.length,i=i?i<0?Math.max(0,n+i):i:0;i<n;i++)if(i in e&&e[i]===t)return i}return-1},merge:function(t,e){for(var i=+e.length,n=0,s=t.length;n<i;)t[s++]=e[n++];if(i!==i)for(;void 0!==e[n];)t[s++]=e[n++];return t.length=s,t},grep:function(t,e,i){for(var n,s=[],o=0,a=t.length,r=!i;o<a;o++)n=!e(t[o],o),n!==r&&s.push(t[o]);return s},map:function(t,e,n){var s,o,a=0,r=[];if(i(t))for(s=t.length;a<s;a++)o=e(t[a],a,n),null!=o&&r.push(o);else for(a in t)o=e(t[a],a,n),null!=o&&r.push(o);return ot.apply([],r)},guid:1,proxy:function(t,e){var i,n,s;if("string"==typeof e&&(s=t[e],e=t,t=s),pt.isFunction(t))return i=st.call(arguments,2),n=function(){return t.apply(e||this,i.concat(st.call(arguments)))},n.guid=t.guid=t.guid||pt.guid++,n},now:function(){return+new Date},support:ht}),"function"==typeof Symbol&&(pt.fn[Symbol.iterator]=it[Symbol.iterator]),pt.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(t,e){lt["[object "+e+"]"]=e.toLowerCase()});var bt=function(t){function e(t,e,i,n){var s,o,a,r,l,d,h,p,m=e&&e.ownerDocument,f=e?e.nodeType:9;if(i=i||[],"string"!=typeof t||!t||1!==f&&9!==f&&11!==f)return i;if(!n&&((e?e.ownerDocument||e:B)!==R&&x(e),e=e||R,O)){if(11!==f&&(d=vt.exec(t)))if(s=d[1]){if(9===f){if(!(a=e.getElementById(s)))return i;if(a.id===s)return i.push(a),i}else if(m&&(a=m.getElementById(s))&&U(e,a)&&a.id===s)return i.push(a),i}else{if(d[2])return Q.apply(i,e.getElementsByTagName(t)),i;if((s=d[3])&&E.getElementsByClassName&&e.getElementsByClassName)return Q.apply(i,e.getElementsByClassName(s)),i}if(E.qsa&&!G[t+" "]&&(!P||!P.test(t))){if(1!==f)m=e,p=t;else if("object"!==e.nodeName.toLowerCase()){for((r=e.getAttribute("id"))?r=r.replace(St,"\\$&"):e.setAttribute("id",r=F),h=w(t),o=h.length,l=ut.test(r)?"#"+r:"[id='"+r+"']";o--;)h[o]=l+" "+u(h[o]);p=h.join(","),m=bt.test(t)&&c(e.parentNode)||e}if(p)try{return Q.apply(i,m.querySelectorAll(p)),i}catch(t){}finally{r===F&&e.removeAttribute("id")}}}return _(t.replace(rt,"$1"),e,i,n)}function i(){function t(i,n){return e.push(i+" ")>T.cacheLength&&delete t[e.shift()],t[i+" "]=n}var e=[];return t}function n(t){return t[F]=!0,t}function s(t){var e=R.createElement("div");try{return!!t(e)}catch(t){return!1}finally{e.parentNode&&e.parentNode.removeChild(e),e=null}}function o(t,e){for(var i=t.split("|"),n=i.length;n--;)T.attrHandle[i[n]]=e}function a(t,e){var i=e&&t,n=i&&1===t.nodeType&&1===e.nodeType&&(~e.sourceIndex||K)-(~t.sourceIndex||K);if(n)return n;if(i)for(;i=i.nextSibling;)if(i===e)return-1;return t?1:-1}function r(t){return function(e){var i=e.nodeName.toLowerCase();return"input"===i&&e.type===t}}function l(t){return function(e){var i=e.nodeName.toLowerCase();return("input"===i||"button"===i)&&e.type===t}}function d(t){return n(function(e){return e=+e,n(function(i,n){for(var s,o=t([],i.length,e),a=o.length;a--;)i[s=o[a]]&&(i[s]=!(n[s]=i[s]))})})}function c(t){return t&&"undefined"!=typeof t.getElementsByTagName&&t}function h(){}function u(t){for(var e=0,i=t.length,n="";e<i;e++)n+=t[e].value;return n}function p(t,e,i){var n=e.dir,s=i&&"parentNode"===n,o=j++;return e.first?function(e,i,o){for(;e=e[n];)if(1===e.nodeType||s)return t(e,i,o)}:function(e,i,a){var r,l,d,c=[H,o];if(a){for(;e=e[n];)if((1===e.nodeType||s)&&t(e,i,a))return!0}else for(;e=e[n];)if(1===e.nodeType||s){if(d=e[F]||(e[F]={}),l=d[e.uniqueID]||(d[e.uniqueID]={}),(r=l[n])&&r[0]===H&&r[1]===o)return c[2]=r[2];if(l[n]=c,c[2]=t(e,i,a))return!0}}}function m(t){return t.length>1?function(e,i,n){for(var s=t.length;s--;)if(!t[s](e,i,n))return!1;return!0}:t[0]}function f(t,i,n){for(var s=0,o=i.length;s<o;s++)e(t,i[s],n);return n}function g(t,e,i,n,s){for(var o,a=[],r=0,l=t.length,d=null!=e;r<l;r++)(o=t[r])&&(i&&!i(o,n,s)||(a.push(o),d&&e.push(r)));return a}function v(t,e,i,s,o,a){return s&&!s[F]&&(s=v(s)),o&&!o[F]&&(o=v(o,a)),n(function(n,a,r,l){var d,c,h,u=[],p=[],m=a.length,v=n||f(e||"*",r.nodeType?[r]:r,[]),b=!t||!n&&e?v:g(v,u,t,r,l),S=i?o||(n?t:m||s)?[]:a:b;if(i&&i(b,S,r,l),s)for(d=g(S,p),s(d,[],r,l),c=d.length;c--;)(h=d[c])&&(S[p[c]]=!(b[p[c]]=h));if(n){if(o||t){if(o){for(d=[],c=S.length;c--;)(h=S[c])&&d.push(b[c]=h);o(null,S=[],d,l)}for(c=S.length;c--;)(h=S[c])&&(d=o?tt(n,h):u[c])>-1&&(n[d]=!(a[d]=h))}}else S=g(S===a?S.splice(m,S.length):S),o?o(null,a,S,l):Q.apply(a,S)})}function b(t){for(var e,i,n,s=t.length,o=T.relative[t[0].type],a=o||T.relative[" "],r=o?1:0,l=p(function(t){return t===e},a,!0),d=p(function(t){return tt(e,t)>-1},a,!0),c=[function(t,i,n){var s=!o&&(n||i!==D)||((e=i).nodeType?l(t,i,n):d(t,i,n));return e=null,s}];r<s;r++)if(i=T.relative[t[r].type])c=[p(m(c),i)];else{if(i=T.filter[t[r].type].apply(null,t[r].matches),i[F]){for(n=++r;n<s&&!T.relative[t[n].type];n++);return v(r>1&&m(c),r>1&&u(t.slice(0,r-1).concat({value:" "===t[r-2].type?"*":""})).replace(rt,"$1"),i,r<n&&b(t.slice(r,n)),n<s&&b(t=t.slice(n)),n<s&&u(t))}c.push(i)}return m(c)}function S(t,i){var s=i.length>0,o=t.length>0,a=function(n,a,r,l,d){var c,h,u,p=0,m="0",f=n&&[],v=[],b=D,S=n||o&&T.find.TAG("*",d),y=H+=null==b?1:Math.random()||.1,E=S.length;for(d&&(D=a===R||a||d);m!==E&&null!=(c=S[m]);m++){if(o&&c){for(h=0,a||c.ownerDocument===R||(x(c),r=!O);u=t[h++];)if(u(c,a||R,r)){l.push(c);break}d&&(H=y)}s&&((c=!u&&c)&&p--,n&&f.push(c))}if(p+=m,s&&m!==p){for(h=0;u=i[h++];)u(f,v,a,r);if(n){if(p>0)for(;m--;)f[m]||v[m]||(v[m]=X.call(l));v=g(v)}Q.apply(l,v),d&&!n&&v.length>0&&p+i.length>1&&e.uniqueSort(l)}return d&&(H=y,D=b),f};return s?n(a):a}var y,E,T,L,k,w,C,_,D,A,I,x,R,M,O,P,N,$,U,F="sizzle"+1*new Date,B=t.document,H=0,j=0,V=i(),z=i(),G=i(),W=function(t,e){return t===e&&(I=!0),0},K=1<<31,Y={}.hasOwnProperty,q=[],X=q.pop,J=q.push,Q=q.push,Z=q.slice,tt=function(t,e){for(var i=0,n=t.length;i<n;i++)if(t[i]===e)return i;return-1},et="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",it="[\\x20\\t\\r\\n\\f]",nt="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",st="\\["+it+"*("+nt+")(?:"+it+"*([*^$|!~]?=)"+it+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+nt+"))|)"+it+"*\\]",ot=":("+nt+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+st+")*)|.*)\\)|)",at=new RegExp(it+"+","g"),rt=new RegExp("^"+it+"+|((?:^|[^\\\\])(?:\\\\.)*)"+it+"+$","g"),lt=new RegExp("^"+it+"*,"+it+"*"),dt=new RegExp("^"+it+"*([>+~]|"+it+")"+it+"*"),ct=new RegExp("="+it+"*([^\\]'\"]*?)"+it+"*\\]","g"),ht=new RegExp(ot),ut=new RegExp("^"+nt+"$"),pt={ID:new RegExp("^#("+nt+")"),CLASS:new RegExp("^\\.("+nt+")"),TAG:new RegExp("^("+nt+"|[*])"),ATTR:new RegExp("^"+st),PSEUDO:new RegExp("^"+ot),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+it+"*(even|odd|(([+-]|)(\\d*)n|)"+it+"*(?:([+-]|)"+it+"*(\\d+)|))"+it+"*\\)|)","i"),bool:new RegExp("^(?:"+et+")$","i"),needsContext:new RegExp("^"+it+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+it+"*((?:-\\d)?\\d*)"+it+"*\\)|)(?=[^-]|$)","i")},mt=/^(?:input|select|textarea|button)$/i,ft=/^h\d$/i,gt=/^[^{]+\{\s*\[native \w/,vt=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,bt=/[+~]/,St=/'|\\/g,yt=new RegExp("\\\\([\\da-f]{1,6}"+it+"?|("+it+")|.)","ig"),Et=function(t,e,i){var n="0x"+e-65536;return n!==n||i?e:n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320)},Tt=function(){x()};try{Q.apply(q=Z.call(B.childNodes),B.childNodes),q[B.childNodes.length].nodeType}catch(t){Q={apply:q.length?function(t,e){
J.apply(t,Z.call(e))}:function(t,e){for(var i=t.length,n=0;t[i++]=e[n++];);t.length=i-1}}}E=e.support={},k=e.isXML=function(t){var e=t&&(t.ownerDocument||t).documentElement;return!!e&&"HTML"!==e.nodeName},x=e.setDocument=function(t){var e,i,n=t?t.ownerDocument||t:B;return n!==R&&9===n.nodeType&&n.documentElement?(R=n,M=R.documentElement,O=!k(R),(i=R.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",Tt,!1):i.attachEvent&&i.attachEvent("onunload",Tt)),E.attributes=s(function(t){return t.className="i",!t.getAttribute("className")}),E.getElementsByTagName=s(function(t){return t.appendChild(R.createComment("")),!t.getElementsByTagName("*").length}),E.getElementsByClassName=gt.test(R.getElementsByClassName),E.getById=s(function(t){return M.appendChild(t).id=F,!R.getElementsByName||!R.getElementsByName(F).length}),E.getById?(T.find.ID=function(t,e){if("undefined"!=typeof e.getElementById&&O){var i=e.getElementById(t);return i?[i]:[]}},T.filter.ID=function(t){var e=t.replace(yt,Et);return function(t){return t.getAttribute("id")===e}}):(delete T.find.ID,T.filter.ID=function(t){var e=t.replace(yt,Et);return function(t){var i="undefined"!=typeof t.getAttributeNode&&t.getAttributeNode("id");return i&&i.value===e}}),T.find.TAG=E.getElementsByTagName?function(t,e){return"undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t):E.qsa?e.querySelectorAll(t):void 0}:function(t,e){var i,n=[],s=0,o=e.getElementsByTagName(t);if("*"===t){for(;i=o[s++];)1===i.nodeType&&n.push(i);return n}return o},T.find.CLASS=E.getElementsByClassName&&function(t,e){if("undefined"!=typeof e.getElementsByClassName&&O)return e.getElementsByClassName(t)},N=[],P=[],(E.qsa=gt.test(R.querySelectorAll))&&(s(function(t){M.appendChild(t).innerHTML="<a id='"+F+"'></a><select id='"+F+"-\r\\' msallowcapture=''><option selected=''></option></select>",t.querySelectorAll("[msallowcapture^='']").length&&P.push("[*^$]="+it+"*(?:''|\"\")"),t.querySelectorAll("[selected]").length||P.push("\\["+it+"*(?:value|"+et+")"),t.querySelectorAll("[id~="+F+"-]").length||P.push("~="),t.querySelectorAll(":checked").length||P.push(":checked"),t.querySelectorAll("a#"+F+"+*").length||P.push(".#.+[+~]")}),s(function(t){var e=R.createElement("input");e.setAttribute("type","hidden"),t.appendChild(e).setAttribute("name","D"),t.querySelectorAll("[name=d]").length&&P.push("name"+it+"*[*^$|!~]?="),t.querySelectorAll(":enabled").length||P.push(":enabled",":disabled"),t.querySelectorAll("*,:x"),P.push(",.*:")})),(E.matchesSelector=gt.test($=M.matches||M.webkitMatchesSelector||M.mozMatchesSelector||M.oMatchesSelector||M.msMatchesSelector))&&s(function(t){E.disconnectedMatch=$.call(t,"div"),$.call(t,"[s!='']:x"),N.push("!=",ot)}),P=P.length&&new RegExp(P.join("|")),N=N.length&&new RegExp(N.join("|")),e=gt.test(M.compareDocumentPosition),U=e||gt.test(M.contains)?function(t,e){var i=9===t.nodeType?t.documentElement:t,n=e&&e.parentNode;return t===n||!(!n||1!==n.nodeType||!(i.contains?i.contains(n):t.compareDocumentPosition&&16&t.compareDocumentPosition(n)))}:function(t,e){if(e)for(;e=e.parentNode;)if(e===t)return!0;return!1},W=e?function(t,e){if(t===e)return I=!0,0;var i=!t.compareDocumentPosition-!e.compareDocumentPosition;return i?i:(i=(t.ownerDocument||t)===(e.ownerDocument||e)?t.compareDocumentPosition(e):1,1&i||!E.sortDetached&&e.compareDocumentPosition(t)===i?t===R||t.ownerDocument===B&&U(B,t)?-1:e===R||e.ownerDocument===B&&U(B,e)?1:A?tt(A,t)-tt(A,e):0:4&i?-1:1)}:function(t,e){if(t===e)return I=!0,0;var i,n=0,s=t.parentNode,o=e.parentNode,r=[t],l=[e];if(!s||!o)return t===R?-1:e===R?1:s?-1:o?1:A?tt(A,t)-tt(A,e):0;if(s===o)return a(t,e);for(i=t;i=i.parentNode;)r.unshift(i);for(i=e;i=i.parentNode;)l.unshift(i);for(;r[n]===l[n];)n++;return n?a(r[n],l[n]):r[n]===B?-1:l[n]===B?1:0},R):R},e.matches=function(t,i){return e(t,null,null,i)},e.matchesSelector=function(t,i){if((t.ownerDocument||t)!==R&&x(t),i=i.replace(ct,"='$1']"),E.matchesSelector&&O&&!G[i+" "]&&(!N||!N.test(i))&&(!P||!P.test(i)))try{var n=$.call(t,i);if(n||E.disconnectedMatch||t.document&&11!==t.document.nodeType)return n}catch(t){}return e(i,R,null,[t]).length>0},e.contains=function(t,e){return(t.ownerDocument||t)!==R&&x(t),U(t,e)},e.attr=function(t,e){(t.ownerDocument||t)!==R&&x(t);var i=T.attrHandle[e.toLowerCase()],n=i&&Y.call(T.attrHandle,e.toLowerCase())?i(t,e,!O):void 0;return void 0!==n?n:E.attributes||!O?t.getAttribute(e):(n=t.getAttributeNode(e))&&n.specified?n.value:null},e.error=function(t){throw new Error("Syntax error, unrecognized expression: "+t)},e.uniqueSort=function(t){var e,i=[],n=0,s=0;if(I=!E.detectDuplicates,A=!E.sortStable&&t.slice(0),t.sort(W),I){for(;e=t[s++];)e===t[s]&&(n=i.push(s));for(;n--;)t.splice(i[n],1)}return A=null,t},L=e.getText=function(t){var e,i="",n=0,s=t.nodeType;if(s){if(1===s||9===s||11===s){if("string"==typeof t.textContent)return t.textContent;for(t=t.firstChild;t;t=t.nextSibling)i+=L(t)}else if(3===s||4===s)return t.nodeValue}else for(;e=t[n++];)i+=L(e);return i},T=e.selectors={cacheLength:50,createPseudo:n,match:pt,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(t){return t[1]=t[1].replace(yt,Et),t[3]=(t[3]||t[4]||t[5]||"").replace(yt,Et),"~="===t[2]&&(t[3]=" "+t[3]+" "),t.slice(0,4)},CHILD:function(t){return t[1]=t[1].toLowerCase(),"nth"===t[1].slice(0,3)?(t[3]||e.error(t[0]),t[4]=+(t[4]?t[5]+(t[6]||1):2*("even"===t[3]||"odd"===t[3])),t[5]=+(t[7]+t[8]||"odd"===t[3])):t[3]&&e.error(t[0]),t},PSEUDO:function(t){var e,i=!t[6]&&t[2];return pt.CHILD.test(t[0])?null:(t[3]?t[2]=t[4]||t[5]||"":i&&ht.test(i)&&(e=w(i,!0))&&(e=i.indexOf(")",i.length-e)-i.length)&&(t[0]=t[0].slice(0,e),t[2]=i.slice(0,e)),t.slice(0,3))}},filter:{TAG:function(t){var e=t.replace(yt,Et).toLowerCase();return"*"===t?function(){return!0}:function(t){return t.nodeName&&t.nodeName.toLowerCase()===e}},CLASS:function(t){var e=V[t+" "];return e||(e=new RegExp("(^|"+it+")"+t+"("+it+"|$)"))&&V(t,function(t){return e.test("string"==typeof t.className&&t.className||"undefined"!=typeof t.getAttribute&&t.getAttribute("class")||"")})},ATTR:function(t,i,n){return function(s){var o=e.attr(s,t);return null==o?"!="===i:!i||(o+="","="===i?o===n:"!="===i?o!==n:"^="===i?n&&0===o.indexOf(n):"*="===i?n&&o.indexOf(n)>-1:"$="===i?n&&o.slice(-n.length)===n:"~="===i?(" "+o.replace(at," ")+" ").indexOf(n)>-1:"|="===i&&(o===n||o.slice(0,n.length+1)===n+"-"))}},CHILD:function(t,e,i,n,s){var o="nth"!==t.slice(0,3),a="last"!==t.slice(-4),r="of-type"===e;return 1===n&&0===s?function(t){return!!t.parentNode}:function(e,i,l){var d,c,h,u,p,m,f=o!==a?"nextSibling":"previousSibling",g=e.parentNode,v=r&&e.nodeName.toLowerCase(),b=!l&&!r,S=!1;if(g){if(o){for(;f;){for(u=e;u=u[f];)if(r?u.nodeName.toLowerCase()===v:1===u.nodeType)return!1;m=f="only"===t&&!m&&"nextSibling"}return!0}if(m=[a?g.firstChild:g.lastChild],a&&b){for(u=g,h=u[F]||(u[F]={}),c=h[u.uniqueID]||(h[u.uniqueID]={}),d=c[t]||[],p=d[0]===H&&d[1],S=p&&d[2],u=p&&g.childNodes[p];u=++p&&u&&u[f]||(S=p=0)||m.pop();)if(1===u.nodeType&&++S&&u===e){c[t]=[H,p,S];break}}else if(b&&(u=e,h=u[F]||(u[F]={}),c=h[u.uniqueID]||(h[u.uniqueID]={}),d=c[t]||[],p=d[0]===H&&d[1],S=p),S===!1)for(;(u=++p&&u&&u[f]||(S=p=0)||m.pop())&&((r?u.nodeName.toLowerCase()!==v:1!==u.nodeType)||!++S||(b&&(h=u[F]||(u[F]={}),c=h[u.uniqueID]||(h[u.uniqueID]={}),c[t]=[H,S]),u!==e)););return S-=s,S===n||S%n===0&&S/n>=0}}},PSEUDO:function(t,i){var s,o=T.pseudos[t]||T.setFilters[t.toLowerCase()]||e.error("unsupported pseudo: "+t);return o[F]?o(i):o.length>1?(s=[t,t,"",i],T.setFilters.hasOwnProperty(t.toLowerCase())?n(function(t,e){for(var n,s=o(t,i),a=s.length;a--;)n=tt(t,s[a]),t[n]=!(e[n]=s[a])}):function(t){return o(t,0,s)}):o}},pseudos:{not:n(function(t){var e=[],i=[],s=C(t.replace(rt,"$1"));return s[F]?n(function(t,e,i,n){for(var o,a=s(t,null,n,[]),r=t.length;r--;)(o=a[r])&&(t[r]=!(e[r]=o))}):function(t,n,o){return e[0]=t,s(e,null,o,i),e[0]=null,!i.pop()}}),has:n(function(t){return function(i){return e(t,i).length>0}}),contains:n(function(t){return t=t.replace(yt,Et),function(e){return(e.textContent||e.innerText||L(e)).indexOf(t)>-1}}),lang:n(function(t){return ut.test(t||"")||e.error("unsupported lang: "+t),t=t.replace(yt,Et).toLowerCase(),function(e){var i;do if(i=O?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return i=i.toLowerCase(),i===t||0===i.indexOf(t+"-");while((e=e.parentNode)&&1===e.nodeType);return!1}}),target:function(e){var i=t.location&&t.location.hash;return i&&i.slice(1)===e.id},root:function(t){return t===M},focus:function(t){return t===R.activeElement&&(!R.hasFocus||R.hasFocus())&&!!(t.type||t.href||~t.tabIndex)},enabled:function(t){return t.disabled===!1},disabled:function(t){return t.disabled===!0},checked:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&!!t.checked||"option"===e&&!!t.selected},selected:function(t){return t.parentNode&&t.parentNode.selectedIndex,t.selected===!0},empty:function(t){for(t=t.firstChild;t;t=t.nextSibling)if(t.nodeType<6)return!1;return!0},parent:function(t){return!T.pseudos.empty(t)},header:function(t){return ft.test(t.nodeName)},input:function(t){return mt.test(t.nodeName)},button:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&"button"===t.type||"button"===e},text:function(t){var e;return"input"===t.nodeName.toLowerCase()&&"text"===t.type&&(null==(e=t.getAttribute("type"))||"text"===e.toLowerCase())},first:d(function(){return[0]}),last:d(function(t,e){return[e-1]}),eq:d(function(t,e,i){return[i<0?i+e:i]}),even:d(function(t,e){for(var i=0;i<e;i+=2)t.push(i);return t}),odd:d(function(t,e){for(var i=1;i<e;i+=2)t.push(i);return t}),lt:d(function(t,e,i){for(var n=i<0?i+e:i;--n>=0;)t.push(n);return t}),gt:d(function(t,e,i){for(var n=i<0?i+e:i;++n<e;)t.push(n);return t})}},T.pseudos.nth=T.pseudos.eq;for(y in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})T.pseudos[y]=r(y);for(y in{submit:!0,reset:!0})T.pseudos[y]=l(y);return h.prototype=T.filters=T.pseudos,T.setFilters=new h,w=e.tokenize=function(t,i){var n,s,o,a,r,l,d,c=z[t+" "];if(c)return i?0:c.slice(0);for(r=t,l=[],d=T.preFilter;r;){n&&!(s=lt.exec(r))||(s&&(r=r.slice(s[0].length)||r),l.push(o=[])),n=!1,(s=dt.exec(r))&&(n=s.shift(),o.push({value:n,type:s[0].replace(rt," ")}),r=r.slice(n.length));for(a in T.filter)!(s=pt[a].exec(r))||d[a]&&!(s=d[a](s))||(n=s.shift(),o.push({value:n,type:a,matches:s}),r=r.slice(n.length));if(!n)break}return i?r.length:r?e.error(t):z(t,l).slice(0)},C=e.compile=function(t,e){var i,n=[],s=[],o=G[t+" "];if(!o){for(e||(e=w(t)),i=e.length;i--;)o=b(e[i]),o[F]?n.push(o):s.push(o);o=G(t,S(s,n)),o.selector=t}return o},_=e.select=function(t,e,i,n){var s,o,a,r,l,d="function"==typeof t&&t,h=!n&&w(t=d.selector||t);if(i=i||[],1===h.length){if(o=h[0]=h[0].slice(0),o.length>2&&"ID"===(a=o[0]).type&&E.getById&&9===e.nodeType&&O&&T.relative[o[1].type]){if(e=(T.find.ID(a.matches[0].replace(yt,Et),e)||[])[0],!e)return i;d&&(e=e.parentNode),t=t.slice(o.shift().value.length)}for(s=pt.needsContext.test(t)?0:o.length;s--&&(a=o[s],!T.relative[r=a.type]);)if((l=T.find[r])&&(n=l(a.matches[0].replace(yt,Et),bt.test(o[0].type)&&c(e.parentNode)||e))){if(o.splice(s,1),t=n.length&&u(o),!t)return Q.apply(i,n),i;break}}return(d||C(t,h))(n,e,!O,i,!e||bt.test(t)&&c(e.parentNode)||e),i},E.sortStable=F.split("").sort(W).join("")===F,E.detectDuplicates=!!I,x(),E.sortDetached=s(function(t){return 1&t.compareDocumentPosition(R.createElement("div"))}),s(function(t){return t.innerHTML="<a href='#'></a>","#"===t.firstChild.getAttribute("href")})||o("type|href|height|width",function(t,e,i){if(!i)return t.getAttribute(e,"type"===e.toLowerCase()?1:2)}),E.attributes&&s(function(t){return t.innerHTML="<input/>",t.firstChild.setAttribute("value",""),""===t.firstChild.getAttribute("value")})||o("value",function(t,e,i){if(!i&&"input"===t.nodeName.toLowerCase())return t.defaultValue}),s(function(t){return null==t.getAttribute("disabled")})||o(et,function(t,e,i){var n;if(!i)return t[e]===!0?e.toLowerCase():(n=t.getAttributeNode(e))&&n.specified?n.value:null}),e}(t);pt.find=bt,pt.expr=bt.selectors,pt.expr[":"]=pt.expr.pseudos,pt.uniqueSort=pt.unique=bt.uniqueSort,pt.text=bt.getText,pt.isXMLDoc=bt.isXML,pt.contains=bt.contains;var St=function(t,e,i){for(var n=[],s=void 0!==i;(t=t[e])&&9!==t.nodeType;)if(1===t.nodeType){if(s&&pt(t).is(i))break;n.push(t)}return n},yt=function(t,e){for(var i=[];t;t=t.nextSibling)1===t.nodeType&&t!==e&&i.push(t);return i},Et=pt.expr.match.needsContext,Tt=/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/,Lt=/^.[^:#\[\.,]*$/;pt.filter=function(t,e,i){var n=e[0];return i&&(t=":not("+t+")"),1===e.length&&1===n.nodeType?pt.find.matchesSelector(n,t)?[n]:[]:pt.find.matches(t,pt.grep(e,function(t){return 1===t.nodeType}))},pt.fn.extend({find:function(t){var e,i=[],n=this,s=n.length;if("string"!=typeof t)return this.pushStack(pt(t).filter(function(){for(e=0;e<s;e++)if(pt.contains(n[e],this))return!0}));for(e=0;e<s;e++)pt.find(t,n[e],i);return i=this.pushStack(s>1?pt.unique(i):i),i.selector=this.selector?this.selector+" "+t:t,i},filter:function(t){return this.pushStack(n(this,t||[],!1))},not:function(t){return this.pushStack(n(this,t||[],!0))},is:function(t){return!!n(this,"string"==typeof t&&Et.test(t)?pt(t):t||[],!1).length}});var kt,wt=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,Ct=pt.fn.init=function(t,e,i){var n,s;if(!t)return this;if(i=i||kt,"string"==typeof t){if(n="<"===t.charAt(0)&&">"===t.charAt(t.length-1)&&t.length>=3?[null,t,null]:wt.exec(t),!n||!n[1]&&e)return!e||e.jquery?(e||i).find(t):this.constructor(e).find(t);if(n[1]){if(e=e instanceof pt?e[0]:e,pt.merge(this,pt.parseHTML(n[1],e&&e.nodeType?e.ownerDocument||e:nt,!0)),Tt.test(n[1])&&pt.isPlainObject(e))for(n in e)pt.isFunction(this[n])?this[n](e[n]):this.attr(n,e[n]);return this}if(s=nt.getElementById(n[2]),s&&s.parentNode){if(s.id!==n[2])return kt.find(t);this.length=1,this[0]=s}return this.context=nt,this.selector=t,this}return t.nodeType?(this.context=this[0]=t,this.length=1,this):pt.isFunction(t)?"undefined"!=typeof i.ready?i.ready(t):t(pt):(void 0!==t.selector&&(this.selector=t.selector,this.context=t.context),pt.makeArray(t,this))};Ct.prototype=pt.fn,kt=pt(nt);var _t=/^(?:parents|prev(?:Until|All))/,Dt={children:!0,contents:!0,next:!0,prev:!0};pt.fn.extend({has:function(t){var e,i=pt(t,this),n=i.length;return this.filter(function(){for(e=0;e<n;e++)if(pt.contains(this,i[e]))return!0})},closest:function(t,e){for(var i,n=0,s=this.length,o=[],a=Et.test(t)||"string"!=typeof t?pt(t,e||this.context):0;n<s;n++)for(i=this[n];i&&i!==e;i=i.parentNode)if(i.nodeType<11&&(a?a.index(i)>-1:1===i.nodeType&&pt.find.matchesSelector(i,t))){o.push(i);break}return this.pushStack(o.length>1?pt.uniqueSort(o):o)},index:function(t){return t?"string"==typeof t?pt.inArray(this[0],pt(t)):pt.inArray(t.jquery?t[0]:t,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(t,e){return this.pushStack(pt.uniqueSort(pt.merge(this.get(),pt(t,e))))},addBack:function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}}),pt.each({parent:function(t){var e=t.parentNode;return e&&11!==e.nodeType?e:null},parents:function(t){return St(t,"parentNode")},parentsUntil:function(t,e,i){return St(t,"parentNode",i)},next:function(t){return s(t,"nextSibling")},prev:function(t){return s(t,"previousSibling")},nextAll:function(t){return St(t,"nextSibling")},prevAll:function(t){return St(t,"previousSibling")},nextUntil:function(t,e,i){return St(t,"nextSibling",i)},prevUntil:function(t,e,i){return St(t,"previousSibling",i)},siblings:function(t){return yt((t.parentNode||{}).firstChild,t)},children:function(t){return yt(t.firstChild)},contents:function(t){return pt.nodeName(t,"iframe")?t.contentDocument||t.contentWindow.document:pt.merge([],t.childNodes)}},function(t,e){pt.fn[t]=function(i,n){var s=pt.map(this,e,i);return"Until"!==t.slice(-5)&&(n=i),n&&"string"==typeof n&&(s=pt.filter(n,s)),this.length>1&&(Dt[t]||(s=pt.uniqueSort(s)),_t.test(t)&&(s=s.reverse())),this.pushStack(s)}});var At=/\S+/g;pt.Callbacks=function(t){t="string"==typeof t?o(t):pt.extend({},t);var e,i,n,s,a=[],r=[],l=-1,d=function(){for(s=t.once,n=e=!0;r.length;l=-1)for(i=r.shift();++l<a.length;)a[l].apply(i[0],i[1])===!1&&t.stopOnFalse&&(l=a.length,i=!1);t.memory||(i=!1),e=!1,s&&(a=i?[]:"")},c={add:function(){return a&&(i&&!e&&(l=a.length-1,r.push(i)),function e(i){pt.each(i,function(i,n){pt.isFunction(n)?t.unique&&c.has(n)||a.push(n):n&&n.length&&"string"!==pt.type(n)&&e(n)})}(arguments),i&&!e&&d()),this},remove:function(){return pt.each(arguments,function(t,e){for(var i;(i=pt.inArray(e,a,i))>-1;)a.splice(i,1),i<=l&&l--}),this},has:function(t){return t?pt.inArray(t,a)>-1:a.length>0},empty:function(){return a&&(a=[]),this},disable:function(){return s=r=[],a=i="",this},disabled:function(){return!a},lock:function(){return s=!0,i||c.disable(),this},locked:function(){return!!s},fireWith:function(t,i){return s||(i=i||[],i=[t,i.slice?i.slice():i],r.push(i),e||d()),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!n}};return c},pt.extend({Deferred:function(t){var e=[["resolve","done",pt.Callbacks("once memory"),"resolved"],["reject","fail",pt.Callbacks("once memory"),"rejected"],["notify","progress",pt.Callbacks("memory")]],i="pending",n={state:function(){return i},always:function(){return s.done(arguments).fail(arguments),this},then:function(){var t=arguments;return pt.Deferred(function(i){pt.each(e,function(e,o){var a=pt.isFunction(t[e])&&t[e];s[o[1]](function(){var t=a&&a.apply(this,arguments);t&&pt.isFunction(t.promise)?t.promise().progress(i.notify).done(i.resolve).fail(i.reject):i[o[0]+"With"](this===n?i.promise():this,a?[t]:arguments)})}),t=null}).promise()},promise:function(t){return null!=t?pt.extend(t,n):n}},s={};return n.pipe=n.then,pt.each(e,function(t,o){var a=o[2],r=o[3];n[o[1]]=a.add,r&&a.add(function(){i=r},e[1^t][2].disable,e[2][2].lock),s[o[0]]=function(){return s[o[0]+"With"](this===s?n:this,arguments),this},s[o[0]+"With"]=a.fireWith}),n.promise(s),t&&t.call(s,s),s},when:function(t){var e,i,n,s=0,o=st.call(arguments),a=o.length,r=1!==a||t&&pt.isFunction(t.promise)?a:0,l=1===r?t:pt.Deferred(),d=function(t,i,n){return function(s){i[t]=this,n[t]=arguments.length>1?st.call(arguments):s,n===e?l.notifyWith(i,n):--r||l.resolveWith(i,n)}};if(a>1)for(e=new Array(a),i=new Array(a),n=new Array(a);s<a;s++)o[s]&&pt.isFunction(o[s].promise)?o[s].promise().progress(d(s,i,e)).done(d(s,n,o)).fail(l.reject):--r;return r||l.resolveWith(n,o),l.promise()}});var It;pt.fn.ready=function(t){return pt.ready.promise().done(t),this},pt.extend({isReady:!1,readyWait:1,holdReady:function(t){t?pt.readyWait++:pt.ready(!0)},ready:function(t){(t===!0?--pt.readyWait:pt.isReady)||(pt.isReady=!0,t!==!0&&--pt.readyWait>0||(It.resolveWith(nt,[pt]),pt.fn.triggerHandler&&(pt(nt).triggerHandler("ready"),pt(nt).off("ready"))))}}),pt.ready.promise=function(e){if(!It)if(It=pt.Deferred(),"complete"===nt.readyState||"loading"!==nt.readyState&&!nt.documentElement.doScroll)t.setTimeout(pt.ready);else if(nt.addEventListener)nt.addEventListener("DOMContentLoaded",r),t.addEventListener("load",r);else{nt.attachEvent("onreadystatechange",r),t.attachEvent("onload",r);var i=!1;try{i=null==t.frameElement&&nt.documentElement}catch(t){}i&&i.doScroll&&!function e(){if(!pt.isReady){try{i.doScroll("left")}catch(i){return t.setTimeout(e,50)}a(),pt.ready()}}()}return It.promise(e)},pt.ready.promise();var xt;for(xt in pt(ht))break;ht.ownFirst="0"===xt,ht.inlineBlockNeedsLayout=!1,pt(function(){var t,e,i,n;i=nt.getElementsByTagName("body")[0],i&&i.style&&(e=nt.createElement("div"),n=nt.createElement("div"),n.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",i.appendChild(n).appendChild(e),"undefined"!=typeof e.style.zoom&&(e.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",ht.inlineBlockNeedsLayout=t=3===e.offsetWidth,t&&(i.style.zoom=1)),i.removeChild(n))}),function(){var t=nt.createElement("div");ht.deleteExpando=!0;try{delete t.test}catch(t){ht.deleteExpando=!1}t=null}();var Rt=function(t){var e=pt.noData[(t.nodeName+" ").toLowerCase()],i=+t.nodeType||1;return(1===i||9===i)&&(!e||e!==!0&&t.getAttribute("classid")===e)},Mt=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Ot=/([A-Z])/g;pt.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(t){return t=t.nodeType?pt.cache[t[pt.expando]]:t[pt.expando],!!t&&!d(t)},data:function(t,e,i){return c(t,e,i)},removeData:function(t,e){return h(t,e)},_data:function(t,e,i){return c(t,e,i,!0)},_removeData:function(t,e){return h(t,e,!0)}}),pt.fn.extend({data:function(t,e){var i,n,s,o=this[0],a=o&&o.attributes;if(void 0===t){if(this.length&&(s=pt.data(o),1===o.nodeType&&!pt._data(o,"parsedAttrs"))){for(i=a.length;i--;)a[i]&&(n=a[i].name,0===n.indexOf("data-")&&(n=pt.camelCase(n.slice(5)),l(o,n,s[n])));pt._data(o,"parsedAttrs",!0)}return s}return"object"==typeof t?this.each(function(){pt.data(this,t)}):arguments.length>1?this.each(function(){pt.data(this,t,e)}):o?l(o,t,pt.data(o,t)):void 0},removeData:function(t){return this.each(function(){pt.removeData(this,t)})}}),pt.extend({queue:function(t,e,i){var n;if(t)return e=(e||"fx")+"queue",n=pt._data(t,e),i&&(!n||pt.isArray(i)?n=pt._data(t,e,pt.makeArray(i)):n.push(i)),n||[]},dequeue:function(t,e){e=e||"fx";var i=pt.queue(t,e),n=i.length,s=i.shift(),o=pt._queueHooks(t,e),a=function(){pt.dequeue(t,e)};"inprogress"===s&&(s=i.shift(),n--),s&&("fx"===e&&i.unshift("inprogress"),delete o.stop,s.call(t,a,o)),!n&&o&&o.empty.fire()},_queueHooks:function(t,e){var i=e+"queueHooks";return pt._data(t,i)||pt._data(t,i,{empty:pt.Callbacks("once memory").add(function(){pt._removeData(t,e+"queue"),pt._removeData(t,i)})})}}),pt.fn.extend({queue:function(t,e){var i=2;return"string"!=typeof t&&(e=t,t="fx",i--),arguments.length<i?pt.queue(this[0],t):void 0===e?this:this.each(function(){var i=pt.queue(this,t,e);pt._queueHooks(this,t),"fx"===t&&"inprogress"!==i[0]&&pt.dequeue(this,t)})},dequeue:function(t){return this.each(function(){pt.dequeue(this,t)})},clearQueue:function(t){return this.queue(t||"fx",[])},promise:function(t,e){var i,n=1,s=pt.Deferred(),o=this,a=this.length,r=function(){--n||s.resolveWith(o,[o])};for("string"!=typeof t&&(e=t,t=void 0),t=t||"fx";a--;)i=pt._data(o[a],t+"queueHooks"),i&&i.empty&&(n++,i.empty.add(r));return r(),s.promise(e)}}),function(){var t;ht.shrinkWrapBlocks=function(){if(null!=t)return t;t=!1;var e,i,n;return i=nt.getElementsByTagName("body")[0],i&&i.style?(e=nt.createElement("div"),n=nt.createElement("div"),n.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",i.appendChild(n).appendChild(e),"undefined"!=typeof e.style.zoom&&(e.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:1px;width:1px;zoom:1",e.appendChild(nt.createElement("div")).style.width="5px",t=3!==e.offsetWidth),i.removeChild(n),t):void 0}}();var Pt=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,Nt=new RegExp("^(?:([+-])=|)("+Pt+")([a-z%]*)$","i"),$t=["Top","Right","Bottom","Left"],Ut=function(t,e){return t=e||t,"none"===pt.css(t,"display")||!pt.contains(t.ownerDocument,t)},Ft=function(t,e,i,n,s,o,a){var r=0,l=t.length,d=null==i;if("object"===pt.type(i)){s=!0;for(r in i)Ft(t,e,r,i[r],!0,o,a)}else if(void 0!==n&&(s=!0,pt.isFunction(n)||(a=!0),d&&(a?(e.call(t,n),e=null):(d=e,e=function(t,e,i){return d.call(pt(t),i)})),e))for(;r<l;r++)e(t[r],i,a?n:n.call(t[r],r,e(t[r],i)));return s?t:d?e.call(t):l?e(t[0],i):o},Bt=/^(?:checkbox|radio)$/i,Ht=/<([\w:-]+)/,jt=/^$|\/(?:java|ecma)script/i,Vt=/^\s+/,zt="abbr|article|aside|audio|bdi|canvas|data|datalist|details|dialog|figcaption|figure|footer|header|hgroup|main|mark|meter|nav|output|picture|progress|section|summary|template|time|video";!function(){var t=nt.createElement("div"),e=nt.createDocumentFragment(),i=nt.createElement("input");t.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",ht.leadingWhitespace=3===t.firstChild.nodeType,ht.tbody=!t.getElementsByTagName("tbody").length,ht.htmlSerialize=!!t.getElementsByTagName("link").length,ht.html5Clone="<:nav></:nav>"!==nt.createElement("nav").cloneNode(!0).outerHTML,i.type="checkbox",i.checked=!0,e.appendChild(i),ht.appendChecked=i.checked,t.innerHTML="<textarea>x</textarea>",ht.noCloneChecked=!!t.cloneNode(!0).lastChild.defaultValue,e.appendChild(t),i=nt.createElement("input"),i.setAttribute("type","radio"),i.setAttribute("checked","checked"),i.setAttribute("name","t"),t.appendChild(i),ht.checkClone=t.cloneNode(!0).cloneNode(!0).lastChild.checked,ht.noCloneEvent=!!t.addEventListener,t[pt.expando]=1,ht.attributes=!t.getAttribute(pt.expando)}();var Gt={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:ht.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]};Gt.optgroup=Gt.option,Gt.tbody=Gt.tfoot=Gt.colgroup=Gt.caption=Gt.thead,Gt.th=Gt.td;var Wt=/<|&#?\w+;/,Kt=/<tbody/i;!function(){var e,i,n=nt.createElement("div");for(e in{submit:!0,change:!0,focusin:!0})i="on"+e,(ht[e]=i in t)||(n.setAttribute(i,"t"),ht[e]=n.attributes[i].expando===!1);n=null}();var Yt=/^(?:input|select|textarea)$/i,qt=/^key/,Xt=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Jt=/^(?:focusinfocus|focusoutblur)$/,Qt=/^([^.]*)(?:\.(.+)|)/;pt.event={global:{},add:function(t,e,i,n,s){var o,a,r,l,d,c,h,u,p,m,f,g=pt._data(t);if(g){for(i.handler&&(l=i,i=l.handler,s=l.selector),i.guid||(i.guid=pt.guid++),(a=g.events)||(a=g.events={}),(c=g.handle)||(c=g.handle=function(t){return"undefined"==typeof pt||t&&pt.event.triggered===t.type?void 0:pt.event.dispatch.apply(c.elem,arguments)},c.elem=t),e=(e||"").match(At)||[""],r=e.length;r--;)o=Qt.exec(e[r])||[],p=f=o[1],m=(o[2]||"").split(".").sort(),p&&(d=pt.event.special[p]||{},p=(s?d.delegateType:d.bindType)||p,d=pt.event.special[p]||{},h=pt.extend({type:p,origType:f,data:n,handler:i,guid:i.guid,selector:s,needsContext:s&&pt.expr.match.needsContext.test(s),namespace:m.join(".")},l),(u=a[p])||(u=a[p]=[],u.delegateCount=0,d.setup&&d.setup.call(t,n,m,c)!==!1||(t.addEventListener?t.addEventListener(p,c,!1):t.attachEvent&&t.attachEvent("on"+p,c))),d.add&&(d.add.call(t,h),h.handler.guid||(h.handler.guid=i.guid)),s?u.splice(u.delegateCount++,0,h):u.push(h),pt.event.global[p]=!0);t=null}},remove:function(t,e,i,n,s){var o,a,r,l,d,c,h,u,p,m,f,g=pt.hasData(t)&&pt._data(t);if(g&&(c=g.events)){for(e=(e||"").match(At)||[""],d=e.length;d--;)if(r=Qt.exec(e[d])||[],p=f=r[1],m=(r[2]||"").split(".").sort(),p){for(h=pt.event.special[p]||{},p=(n?h.delegateType:h.bindType)||p,u=c[p]||[],r=r[2]&&new RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"),l=o=u.length;o--;)a=u[o],!s&&f!==a.origType||i&&i.guid!==a.guid||r&&!r.test(a.namespace)||n&&n!==a.selector&&("**"!==n||!a.selector)||(u.splice(o,1),a.selector&&u.delegateCount--,h.remove&&h.remove.call(t,a));l&&!u.length&&(h.teardown&&h.teardown.call(t,m,g.handle)!==!1||pt.removeEvent(t,p,g.handle),delete c[p])}else for(p in c)pt.event.remove(t,p+e[d],i,n,!0);pt.isEmptyObject(c)&&(delete g.handle,pt._removeData(t,"events"))}},trigger:function(e,i,n,s){var o,a,r,l,d,c,h,u=[n||nt],p=ct.call(e,"type")?e.type:e,m=ct.call(e,"namespace")?e.namespace.split("."):[];if(r=c=n=n||nt,3!==n.nodeType&&8!==n.nodeType&&!Jt.test(p+pt.event.triggered)&&(p.indexOf(".")>-1&&(m=p.split("."),p=m.shift(),m.sort()),a=p.indexOf(":")<0&&"on"+p,e=e[pt.expando]?e:new pt.Event(p,"object"==typeof e&&e),e.isTrigger=s?2:3,e.namespace=m.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),i=null==i?[e]:pt.makeArray(i,[e]),d=pt.event.special[p]||{},s||!d.trigger||d.trigger.apply(n,i)!==!1)){if(!s&&!d.noBubble&&!pt.isWindow(n)){for(l=d.delegateType||p,Jt.test(l+p)||(r=r.parentNode);r;r=r.parentNode)u.push(r),c=r;c===(n.ownerDocument||nt)&&u.push(c.defaultView||c.parentWindow||t)}for(h=0;(r=u[h++])&&!e.isPropagationStopped();)e.type=h>1?l:d.bindType||p,o=(pt._data(r,"events")||{})[e.type]&&pt._data(r,"handle"),o&&o.apply(r,i),o=a&&r[a],o&&o.apply&&Rt(r)&&(e.result=o.apply(r,i),e.result===!1&&e.preventDefault());if(e.type=p,!s&&!e.isDefaultPrevented()&&(!d._default||d._default.apply(u.pop(),i)===!1)&&Rt(n)&&a&&n[p]&&!pt.isWindow(n)){c=n[a],c&&(n[a]=null),pt.event.triggered=p;try{n[p]()}catch(t){}pt.event.triggered=void 0,c&&(n[a]=c)}return e.result}},dispatch:function(t){t=pt.event.fix(t);var e,i,n,s,o,a=[],r=st.call(arguments),l=(pt._data(this,"events")||{})[t.type]||[],d=pt.event.special[t.type]||{};if(r[0]=t,t.delegateTarget=this,!d.preDispatch||d.preDispatch.call(this,t)!==!1){for(a=pt.event.handlers.call(this,t,l),e=0;(s=a[e++])&&!t.isPropagationStopped();)for(t.currentTarget=s.elem,i=0;(o=s.handlers[i++])&&!t.isImmediatePropagationStopped();)t.rnamespace&&!t.rnamespace.test(o.namespace)||(t.handleObj=o,t.data=o.data,n=((pt.event.special[o.origType]||{}).handle||o.handler).apply(s.elem,r),void 0!==n&&(t.result=n)===!1&&(t.preventDefault(),t.stopPropagation()));return d.postDispatch&&d.postDispatch.call(this,t),t.result}},handlers:function(t,e){var i,n,s,o,a=[],r=e.delegateCount,l=t.target;if(r&&l.nodeType&&("click"!==t.type||isNaN(t.button)||t.button<1))for(;l!=this;l=l.parentNode||this)if(1===l.nodeType&&(l.disabled!==!0||"click"!==t.type)){for(n=[],i=0;i<r;i++)o=e[i],s=o.selector+" ",void 0===n[s]&&(n[s]=o.needsContext?pt(s,this).index(l)>-1:pt.find(s,this,null,[l]).length),n[s]&&n.push(o);n.length&&a.push({elem:l,handlers:n})}return r<e.length&&a.push({elem:this,handlers:e.slice(r)}),a},fix:function(t){if(t[pt.expando])return t;var e,i,n,s=t.type,o=t,a=this.fixHooks[s];for(a||(this.fixHooks[s]=a=Xt.test(s)?this.mouseHooks:qt.test(s)?this.keyHooks:{}),n=a.props?this.props.concat(a.props):this.props,t=new pt.Event(o),e=n.length;e--;)i=n[e],t[i]=o[i];return t.target||(t.target=o.srcElement||nt),3===t.target.nodeType&&(t.target=t.target.parentNode),t.metaKey=!!t.metaKey,a.filter?a.filter(t,o):t},props:"altKey bubbles cancelable ctrlKey currentTarget detail eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(t,e){return null==t.which&&(t.which=null!=e.charCode?e.charCode:e.keyCode),t}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(t,e){var i,n,s,o=e.button,a=e.fromElement;return null==t.pageX&&null!=e.clientX&&(n=t.target.ownerDocument||nt,s=n.documentElement,i=n.body,t.pageX=e.clientX+(s&&s.scrollLeft||i&&i.scrollLeft||0)-(s&&s.clientLeft||i&&i.clientLeft||0),t.pageY=e.clientY+(s&&s.scrollTop||i&&i.scrollTop||0)-(s&&s.clientTop||i&&i.clientTop||0)),!t.relatedTarget&&a&&(t.relatedTarget=a===t.target?e.toElement:a),t.which||void 0===o||(t.which=1&o?1:2&o?3:4&o?2:0),t}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==y()&&this.focus)try{return this.focus(),!1}catch(t){}},delegateType:"focusin"},blur:{trigger:function(){if(this===y()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if(pt.nodeName(this,"input")&&"checkbox"===this.type&&this.click)return this.click(),!1},_default:function(t){return pt.nodeName(t.target,"a")}},beforeunload:{postDispatch:function(t){void 0!==t.result&&t.originalEvent&&(t.originalEvent.returnValue=t.result)}}},simulate:function(t,e,i){var n=pt.extend(new pt.Event,i,{type:t,isSimulated:!0});pt.event.trigger(n,null,e),n.isDefaultPrevented()&&i.preventDefault()}},pt.removeEvent=nt.removeEventListener?function(t,e,i){t.removeEventListener&&t.removeEventListener(e,i)}:function(t,e,i){var n="on"+e;t.detachEvent&&("undefined"==typeof t[n]&&(t[n]=null),t.detachEvent(n,i))},pt.Event=function(t,e){return this instanceof pt.Event?(t&&t.type?(this.originalEvent=t,this.type=t.type,this.isDefaultPrevented=t.defaultPrevented||void 0===t.defaultPrevented&&t.returnValue===!1?b:S):this.type=t,e&&pt.extend(this,e),this.timeStamp=t&&t.timeStamp||pt.now(),void(this[pt.expando]=!0)):new pt.Event(t,e)},pt.Event.prototype={constructor:pt.Event,isDefaultPrevented:S,isPropagationStopped:S,isImmediatePropagationStopped:S,preventDefault:function(){var t=this.originalEvent;this.isDefaultPrevented=b,t&&(t.preventDefault?t.preventDefault():t.returnValue=!1)},stopPropagation:function(){
var t=this.originalEvent;this.isPropagationStopped=b,t&&!this.isSimulated&&(t.stopPropagation&&t.stopPropagation(),t.cancelBubble=!0)},stopImmediatePropagation:function(){var t=this.originalEvent;this.isImmediatePropagationStopped=b,t&&t.stopImmediatePropagation&&t.stopImmediatePropagation(),this.stopPropagation()}},pt.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(t,e){pt.event.special[t]={delegateType:e,bindType:e,handle:function(t){var i,n=this,s=t.relatedTarget,o=t.handleObj;return s&&(s===n||pt.contains(n,s))||(t.type=o.origType,i=o.handler.apply(this,arguments),t.type=e),i}}}),ht.submit||(pt.event.special.submit={setup:function(){return!pt.nodeName(this,"form")&&void pt.event.add(this,"click._submit keypress._submit",function(t){var e=t.target,i=pt.nodeName(e,"input")||pt.nodeName(e,"button")?pt.prop(e,"form"):void 0;i&&!pt._data(i,"submit")&&(pt.event.add(i,"submit._submit",function(t){t._submitBubble=!0}),pt._data(i,"submit",!0))})},postDispatch:function(t){t._submitBubble&&(delete t._submitBubble,this.parentNode&&!t.isTrigger&&pt.event.simulate("submit",this.parentNode,t))},teardown:function(){return!pt.nodeName(this,"form")&&void pt.event.remove(this,"._submit")}}),ht.change||(pt.event.special.change={setup:function(){return Yt.test(this.nodeName)?("checkbox"!==this.type&&"radio"!==this.type||(pt.event.add(this,"propertychange._change",function(t){"checked"===t.originalEvent.propertyName&&(this._justChanged=!0)}),pt.event.add(this,"click._change",function(t){this._justChanged&&!t.isTrigger&&(this._justChanged=!1),pt.event.simulate("change",this,t)})),!1):void pt.event.add(this,"beforeactivate._change",function(t){var e=t.target;Yt.test(e.nodeName)&&!pt._data(e,"change")&&(pt.event.add(e,"change._change",function(t){!this.parentNode||t.isSimulated||t.isTrigger||pt.event.simulate("change",this.parentNode,t)}),pt._data(e,"change",!0))})},handle:function(t){var e=t.target;if(this!==e||t.isSimulated||t.isTrigger||"radio"!==e.type&&"checkbox"!==e.type)return t.handleObj.handler.apply(this,arguments)},teardown:function(){return pt.event.remove(this,"._change"),!Yt.test(this.nodeName)}}),ht.focusin||pt.each({focus:"focusin",blur:"focusout"},function(t,e){var i=function(t){pt.event.simulate(e,t.target,pt.event.fix(t))};pt.event.special[e]={setup:function(){var n=this.ownerDocument||this,s=pt._data(n,e);s||n.addEventListener(t,i,!0),pt._data(n,e,(s||0)+1)},teardown:function(){var n=this.ownerDocument||this,s=pt._data(n,e)-1;s?pt._data(n,e,s):(n.removeEventListener(t,i,!0),pt._removeData(n,e))}}}),pt.fn.extend({on:function(t,e,i,n){return E(this,t,e,i,n)},one:function(t,e,i,n){return E(this,t,e,i,n,1)},off:function(t,e,i){var n,s;if(t&&t.preventDefault&&t.handleObj)return n=t.handleObj,pt(t.delegateTarget).off(n.namespace?n.origType+"."+n.namespace:n.origType,n.selector,n.handler),this;if("object"==typeof t){for(s in t)this.off(s,e,t[s]);return this}return e!==!1&&"function"!=typeof e||(i=e,e=void 0),i===!1&&(i=S),this.each(function(){pt.event.remove(this,t,i,e)})},trigger:function(t,e){return this.each(function(){pt.event.trigger(t,e,this)})},triggerHandler:function(t,e){var i=this[0];if(i)return pt.event.trigger(t,e,i,!0)}});var Zt=/ jQuery\d+="(?:null|\d+)"/g,te=new RegExp("<(?:"+zt+")[\\s/>]","i"),ee=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,ie=/<script|<style|<link/i,ne=/checked\s*(?:[^=]|=\s*.checked.)/i,se=/^true\/(.*)/,oe=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ae=p(nt),re=ae.appendChild(nt.createElement("div"));pt.extend({htmlPrefilter:function(t){return t.replace(ee,"<$1></$2>")},clone:function(t,e,i){var n,s,o,a,r,l=pt.contains(t.ownerDocument,t);if(ht.html5Clone||pt.isXMLDoc(t)||!te.test("<"+t.nodeName+">")?o=t.cloneNode(!0):(re.innerHTML=t.outerHTML,re.removeChild(o=re.firstChild)),!(ht.noCloneEvent&&ht.noCloneChecked||1!==t.nodeType&&11!==t.nodeType||pt.isXMLDoc(t)))for(n=m(o),r=m(t),a=0;null!=(s=r[a]);++a)n[a]&&C(s,n[a]);if(e)if(i)for(r=r||m(t),n=n||m(o),a=0;null!=(s=r[a]);a++)w(s,n[a]);else w(t,o);return n=m(o,"script"),n.length>0&&f(n,!l&&m(t,"script")),n=r=s=null,o},cleanData:function(t,e){for(var i,n,s,o,a=0,r=pt.expando,l=pt.cache,d=ht.attributes,c=pt.event.special;null!=(i=t[a]);a++)if((e||Rt(i))&&(s=i[r],o=s&&l[s])){if(o.events)for(n in o.events)c[n]?pt.event.remove(i,n):pt.removeEvent(i,n,o.handle);l[s]&&(delete l[s],d||"undefined"==typeof i.removeAttribute?i[r]=void 0:i.removeAttribute(r),it.push(s))}}}),pt.fn.extend({domManip:_,detach:function(t){return D(this,t,!0)},remove:function(t){return D(this,t)},text:function(t){return Ft(this,function(t){return void 0===t?pt.text(this):this.empty().append((this[0]&&this[0].ownerDocument||nt).createTextNode(t))},null,t,arguments.length)},append:function(){return _(this,arguments,function(t){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var e=T(this,t);e.appendChild(t)}})},prepend:function(){return _(this,arguments,function(t){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var e=T(this,t);e.insertBefore(t,e.firstChild)}})},before:function(){return _(this,arguments,function(t){this.parentNode&&this.parentNode.insertBefore(t,this)})},after:function(){return _(this,arguments,function(t){this.parentNode&&this.parentNode.insertBefore(t,this.nextSibling)})},empty:function(){for(var t,e=0;null!=(t=this[e]);e++){for(1===t.nodeType&&pt.cleanData(m(t,!1));t.firstChild;)t.removeChild(t.firstChild);t.options&&pt.nodeName(t,"select")&&(t.options.length=0)}return this},clone:function(t,e){return t=null!=t&&t,e=null==e?t:e,this.map(function(){return pt.clone(this,t,e)})},html:function(t){return Ft(this,function(t){var e=this[0]||{},i=0,n=this.length;if(void 0===t)return 1===e.nodeType?e.innerHTML.replace(Zt,""):void 0;if("string"==typeof t&&!ie.test(t)&&(ht.htmlSerialize||!te.test(t))&&(ht.leadingWhitespace||!Vt.test(t))&&!Gt[(Ht.exec(t)||["",""])[1].toLowerCase()]){t=pt.htmlPrefilter(t);try{for(;i<n;i++)e=this[i]||{},1===e.nodeType&&(pt.cleanData(m(e,!1)),e.innerHTML=t);e=0}catch(t){}}e&&this.empty().append(t)},null,t,arguments.length)},replaceWith:function(){var t=[];return _(this,arguments,function(e){var i=this.parentNode;pt.inArray(this,t)<0&&(pt.cleanData(m(this)),i&&i.replaceChild(e,this))},t)}}),pt.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(t,e){pt.fn[t]=function(t){for(var i,n=0,s=[],o=pt(t),a=o.length-1;n<=a;n++)i=n===a?this:this.clone(!0),pt(o[n])[e](i),at.apply(s,i.get());return this.pushStack(s)}});var le,de={HTML:"block",BODY:"block"},ce=/^margin/,he=new RegExp("^("+Pt+")(?!px)[a-z%]+$","i"),ue=function(t,e,i,n){var s,o,a={};for(o in e)a[o]=t.style[o],t.style[o]=e[o];s=i.apply(t,n||[]);for(o in e)t.style[o]=a[o];return s},pe=nt.documentElement;!function(){function e(){var e,c,h=nt.documentElement;h.appendChild(l),d.style.cssText="-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;display:block;margin:auto;border:1px;padding:1px;top:1%;width:50%",i=s=r=!1,n=a=!0,t.getComputedStyle&&(c=t.getComputedStyle(d),i="1%"!==(c||{}).top,r="2px"===(c||{}).marginLeft,s="4px"===(c||{width:"4px"}).width,d.style.marginRight="50%",n="4px"===(c||{marginRight:"4px"}).marginRight,e=d.appendChild(nt.createElement("div")),e.style.cssText=d.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",e.style.marginRight=e.style.width="0",d.style.width="1px",a=!parseFloat((t.getComputedStyle(e)||{}).marginRight),d.removeChild(e)),d.style.display="none",o=0===d.getClientRects().length,o&&(d.style.display="",d.innerHTML="<table><tr><td></td><td>t</td></tr></table>",d.childNodes[0].style.borderCollapse="separate",e=d.getElementsByTagName("td"),e[0].style.cssText="margin:0;border:0;padding:0;display:none",o=0===e[0].offsetHeight,o&&(e[0].style.display="",e[1].style.display="none",o=0===e[0].offsetHeight)),h.removeChild(l)}var i,n,s,o,a,r,l=nt.createElement("div"),d=nt.createElement("div");d.style&&(d.style.cssText="float:left;opacity:.5",ht.opacity="0.5"===d.style.opacity,ht.cssFloat=!!d.style.cssFloat,d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",ht.clearCloneStyle="content-box"===d.style.backgroundClip,l=nt.createElement("div"),l.style.cssText="border:0;width:8px;height:0;top:0;left:-9999px;padding:0;margin-top:1px;position:absolute",d.innerHTML="",l.appendChild(d),ht.boxSizing=""===d.style.boxSizing||""===d.style.MozBoxSizing||""===d.style.WebkitBoxSizing,pt.extend(ht,{reliableHiddenOffsets:function(){return null==i&&e(),o},boxSizingReliable:function(){return null==i&&e(),s},pixelMarginRight:function(){return null==i&&e(),n},pixelPosition:function(){return null==i&&e(),i},reliableMarginRight:function(){return null==i&&e(),a},reliableMarginLeft:function(){return null==i&&e(),r}}))}();var me,fe,ge=/^(top|right|bottom|left)$/;t.getComputedStyle?(me=function(e){var i=e.ownerDocument.defaultView;return i&&i.opener||(i=t),i.getComputedStyle(e)},fe=function(t,e,i){var n,s,o,a,r=t.style;return i=i||me(t),a=i?i.getPropertyValue(e)||i[e]:void 0,""!==a&&void 0!==a||pt.contains(t.ownerDocument,t)||(a=pt.style(t,e)),i&&!ht.pixelMarginRight()&&he.test(a)&&ce.test(e)&&(n=r.width,s=r.minWidth,o=r.maxWidth,r.minWidth=r.maxWidth=r.width=a,a=i.width,r.width=n,r.minWidth=s,r.maxWidth=o),void 0===a?a:a+""}):pe.currentStyle&&(me=function(t){return t.currentStyle},fe=function(t,e,i){var n,s,o,a,r=t.style;return i=i||me(t),a=i?i[e]:void 0,null==a&&r&&r[e]&&(a=r[e]),he.test(a)&&!ge.test(e)&&(n=r.left,s=t.runtimeStyle,o=s&&s.left,o&&(s.left=t.currentStyle.left),r.left="fontSize"===e?"1em":a,a=r.pixelLeft+"px",r.left=n,o&&(s.left=o)),void 0===a?a:a+""||"auto"});var ve=/alpha\([^)]*\)/i,be=/opacity\s*=\s*([^)]*)/i,Se=/^(none|table(?!-c[ea]).+)/,ye=new RegExp("^("+Pt+")(.*)$","i"),Ee={position:"absolute",visibility:"hidden",display:"block"},Te={letterSpacing:"0",fontWeight:"400"},Le=["Webkit","O","Moz","ms"],ke=nt.createElement("div").style;pt.extend({cssHooks:{opacity:{get:function(t,e){if(e){var i=fe(t,"opacity");return""===i?"1":i}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":ht.cssFloat?"cssFloat":"styleFloat"},style:function(t,e,i,n){if(t&&3!==t.nodeType&&8!==t.nodeType&&t.style){var s,o,a,r=pt.camelCase(e),l=t.style;if(e=pt.cssProps[r]||(pt.cssProps[r]=R(r)||r),a=pt.cssHooks[e]||pt.cssHooks[r],void 0===i)return a&&"get"in a&&void 0!==(s=a.get(t,!1,n))?s:l[e];if(o=typeof i,"string"===o&&(s=Nt.exec(i))&&s[1]&&(i=u(t,e,s),o="number"),null!=i&&i===i&&("number"===o&&(i+=s&&s[3]||(pt.cssNumber[r]?"":"px")),ht.clearCloneStyle||""!==i||0!==e.indexOf("background")||(l[e]="inherit"),!(a&&"set"in a&&void 0===(i=a.set(t,i,n)))))try{l[e]=i}catch(t){}}},css:function(t,e,i,n){var s,o,a,r=pt.camelCase(e);return e=pt.cssProps[r]||(pt.cssProps[r]=R(r)||r),a=pt.cssHooks[e]||pt.cssHooks[r],a&&"get"in a&&(o=a.get(t,!0,i)),void 0===o&&(o=fe(t,e,n)),"normal"===o&&e in Te&&(o=Te[e]),""===i||i?(s=parseFloat(o),i===!0||isFinite(s)?s||0:o):o}}),pt.each(["height","width"],function(t,e){pt.cssHooks[e]={get:function(t,i,n){if(i)return Se.test(pt.css(t,"display"))&&0===t.offsetWidth?ue(t,Ee,function(){return N(t,e,n)}):N(t,e,n)},set:function(t,i,n){var s=n&&me(t);return O(t,i,n?P(t,e,n,ht.boxSizing&&"border-box"===pt.css(t,"boxSizing",!1,s),s):0)}}}),ht.opacity||(pt.cssHooks.opacity={get:function(t,e){return be.test((e&&t.currentStyle?t.currentStyle.filter:t.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":e?"1":""},set:function(t,e){var i=t.style,n=t.currentStyle,s=pt.isNumeric(e)?"alpha(opacity="+100*e+")":"",o=n&&n.filter||i.filter||"";i.zoom=1,(e>=1||""===e)&&""===pt.trim(o.replace(ve,""))&&i.removeAttribute&&(i.removeAttribute("filter"),""===e||n&&!n.filter)||(i.filter=ve.test(o)?o.replace(ve,s):o+" "+s)}}),pt.cssHooks.marginRight=x(ht.reliableMarginRight,function(t,e){if(e)return ue(t,{display:"inline-block"},fe,[t,"marginRight"])}),pt.cssHooks.marginLeft=x(ht.reliableMarginLeft,function(t,e){if(e)return(parseFloat(fe(t,"marginLeft"))||(pt.contains(t.ownerDocument,t)?t.getBoundingClientRect().left-ue(t,{marginLeft:0},function(){return t.getBoundingClientRect().left}):0))+"px"}),pt.each({margin:"",padding:"",border:"Width"},function(t,e){pt.cssHooks[t+e]={expand:function(i){for(var n=0,s={},o="string"==typeof i?i.split(" "):[i];n<4;n++)s[t+$t[n]+e]=o[n]||o[n-2]||o[0];return s}},ce.test(t)||(pt.cssHooks[t+e].set=O)}),pt.fn.extend({css:function(t,e){return Ft(this,function(t,e,i){var n,s,o={},a=0;if(pt.isArray(e)){for(n=me(t),s=e.length;a<s;a++)o[e[a]]=pt.css(t,e[a],!1,n);return o}return void 0!==i?pt.style(t,e,i):pt.css(t,e)},t,e,arguments.length>1)},show:function(){return M(this,!0)},hide:function(){return M(this)},toggle:function(t){return"boolean"==typeof t?t?this.show():this.hide():this.each(function(){Ut(this)?pt(this).show():pt(this).hide()})}}),pt.Tween=$,$.prototype={constructor:$,init:function(t,e,i,n,s,o){this.elem=t,this.prop=i,this.easing=s||pt.easing._default,this.options=e,this.start=this.now=this.cur(),this.end=n,this.unit=o||(pt.cssNumber[i]?"":"px")},cur:function(){var t=$.propHooks[this.prop];return t&&t.get?t.get(this):$.propHooks._default.get(this)},run:function(t){var e,i=$.propHooks[this.prop];return this.options.duration?this.pos=e=pt.easing[this.easing](t,this.options.duration*t,0,1,this.options.duration):this.pos=e=t,this.now=(this.end-this.start)*e+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),i&&i.set?i.set(this):$.propHooks._default.set(this),this}},$.prototype.init.prototype=$.prototype,$.propHooks={_default:{get:function(t){var e;return 1!==t.elem.nodeType||null!=t.elem[t.prop]&&null==t.elem.style[t.prop]?t.elem[t.prop]:(e=pt.css(t.elem,t.prop,""),e&&"auto"!==e?e:0)},set:function(t){pt.fx.step[t.prop]?pt.fx.step[t.prop](t):1!==t.elem.nodeType||null==t.elem.style[pt.cssProps[t.prop]]&&!pt.cssHooks[t.prop]?t.elem[t.prop]=t.now:pt.style(t.elem,t.prop,t.now+t.unit)}}},$.propHooks.scrollTop=$.propHooks.scrollLeft={set:function(t){t.elem.nodeType&&t.elem.parentNode&&(t.elem[t.prop]=t.now)}},pt.easing={linear:function(t){return t},swing:function(t){return.5-Math.cos(t*Math.PI)/2},_default:"swing"},pt.fx=$.prototype.init,pt.fx.step={};var we,Ce,_e=/^(?:toggle|show|hide)$/,De=/queueHooks$/;pt.Animation=pt.extend(V,{tweeners:{"*":[function(t,e){var i=this.createTween(t,e);return u(i.elem,t,Nt.exec(e),i),i}]},tweener:function(t,e){pt.isFunction(t)?(e=t,t=["*"]):t=t.match(At);for(var i,n=0,s=t.length;n<s;n++)i=t[n],V.tweeners[i]=V.tweeners[i]||[],V.tweeners[i].unshift(e)},prefilters:[H],prefilter:function(t,e){e?V.prefilters.unshift(t):V.prefilters.push(t)}}),pt.speed=function(t,e,i){var n=t&&"object"==typeof t?pt.extend({},t):{complete:i||!i&&e||pt.isFunction(t)&&t,duration:t,easing:i&&e||e&&!pt.isFunction(e)&&e};return n.duration=pt.fx.off?0:"number"==typeof n.duration?n.duration:n.duration in pt.fx.speeds?pt.fx.speeds[n.duration]:pt.fx.speeds._default,null!=n.queue&&n.queue!==!0||(n.queue="fx"),n.old=n.complete,n.complete=function(){pt.isFunction(n.old)&&n.old.call(this),n.queue&&pt.dequeue(this,n.queue)},n},pt.fn.extend({fadeTo:function(t,e,i,n){return this.filter(Ut).css("opacity",0).show().end().animate({opacity:e},t,i,n)},animate:function(t,e,i,n){var s=pt.isEmptyObject(t),o=pt.speed(e,i,n),a=function(){var e=V(this,pt.extend({},t),o);(s||pt._data(this,"finish"))&&e.stop(!0)};return a.finish=a,s||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(t,e,i){var n=function(t){var e=t.stop;delete t.stop,e(i)};return"string"!=typeof t&&(i=e,e=t,t=void 0),e&&t!==!1&&this.queue(t||"fx",[]),this.each(function(){var e=!0,s=null!=t&&t+"queueHooks",o=pt.timers,a=pt._data(this);if(s)a[s]&&a[s].stop&&n(a[s]);else for(s in a)a[s]&&a[s].stop&&De.test(s)&&n(a[s]);for(s=o.length;s--;)o[s].elem!==this||null!=t&&o[s].queue!==t||(o[s].anim.stop(i),e=!1,o.splice(s,1));!e&&i||pt.dequeue(this,t)})},finish:function(t){return t!==!1&&(t=t||"fx"),this.each(function(){var e,i=pt._data(this),n=i[t+"queue"],s=i[t+"queueHooks"],o=pt.timers,a=n?n.length:0;for(i.finish=!0,pt.queue(this,t,[]),s&&s.stop&&s.stop.call(this,!0),e=o.length;e--;)o[e].elem===this&&o[e].queue===t&&(o[e].anim.stop(!0),o.splice(e,1));for(e=0;e<a;e++)n[e]&&n[e].finish&&n[e].finish.call(this);delete i.finish})}}),pt.each(["toggle","show","hide"],function(t,e){var i=pt.fn[e];pt.fn[e]=function(t,n,s){return null==t||"boolean"==typeof t?i.apply(this,arguments):this.animate(F(e,!0),t,n,s)}}),pt.each({slideDown:F("show"),slideUp:F("hide"),slideToggle:F("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(t,e){pt.fn[t]=function(t,i,n){return this.animate(e,t,i,n)}}),pt.timers=[],pt.fx.tick=function(){var t,e=pt.timers,i=0;for(we=pt.now();i<e.length;i++)t=e[i],t()||e[i]!==t||e.splice(i--,1);e.length||pt.fx.stop(),we=void 0},pt.fx.timer=function(t){pt.timers.push(t),t()?pt.fx.start():pt.timers.pop()},pt.fx.interval=13,pt.fx.start=function(){Ce||(Ce=t.setInterval(pt.fx.tick,pt.fx.interval))},pt.fx.stop=function(){t.clearInterval(Ce),Ce=null},pt.fx.speeds={slow:600,fast:200,_default:400},pt.fn.delay=function(e,i){return e=pt.fx?pt.fx.speeds[e]||e:e,i=i||"fx",this.queue(i,function(i,n){var s=t.setTimeout(i,e);n.stop=function(){t.clearTimeout(s)}})},function(){var t,e=nt.createElement("input"),i=nt.createElement("div"),n=nt.createElement("select"),s=n.appendChild(nt.createElement("option"));i=nt.createElement("div"),i.setAttribute("className","t"),i.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",t=i.getElementsByTagName("a")[0],e.setAttribute("type","checkbox"),i.appendChild(e),t=i.getElementsByTagName("a")[0],t.style.cssText="top:1px",ht.getSetAttribute="t"!==i.className,ht.style=/top/.test(t.getAttribute("style")),ht.hrefNormalized="/a"===t.getAttribute("href"),ht.checkOn=!!e.value,ht.optSelected=s.selected,ht.enctype=!!nt.createElement("form").enctype,n.disabled=!0,ht.optDisabled=!s.disabled,e=nt.createElement("input"),e.setAttribute("value",""),ht.input=""===e.getAttribute("value"),e.value="t",e.setAttribute("type","radio"),ht.radioValue="t"===e.value}();var Ae=/\r/g,Ie=/[\x20\t\r\n\f]+/g;pt.fn.extend({val:function(t){var e,i,n,s=this[0];{if(arguments.length)return n=pt.isFunction(t),this.each(function(i){var s;1===this.nodeType&&(s=n?t.call(this,i,pt(this).val()):t,null==s?s="":"number"==typeof s?s+="":pt.isArray(s)&&(s=pt.map(s,function(t){return null==t?"":t+""})),e=pt.valHooks[this.type]||pt.valHooks[this.nodeName.toLowerCase()],e&&"set"in e&&void 0!==e.set(this,s,"value")||(this.value=s))});if(s)return e=pt.valHooks[s.type]||pt.valHooks[s.nodeName.toLowerCase()],e&&"get"in e&&void 0!==(i=e.get(s,"value"))?i:(i=s.value,"string"==typeof i?i.replace(Ae,""):null==i?"":i)}}}),pt.extend({valHooks:{option:{get:function(t){var e=pt.find.attr(t,"value");return null!=e?e:pt.trim(pt.text(t)).replace(Ie," ")}},select:{get:function(t){for(var e,i,n=t.options,s=t.selectedIndex,o="select-one"===t.type||s<0,a=o?null:[],r=o?s+1:n.length,l=s<0?r:o?s:0;l<r;l++)if(i=n[l],(i.selected||l===s)&&(ht.optDisabled?!i.disabled:null===i.getAttribute("disabled"))&&(!i.parentNode.disabled||!pt.nodeName(i.parentNode,"optgroup"))){if(e=pt(i).val(),o)return e;a.push(e)}return a},set:function(t,e){for(var i,n,s=t.options,o=pt.makeArray(e),a=s.length;a--;)if(n=s[a],pt.inArray(pt.valHooks.option.get(n),o)>-1)try{n.selected=i=!0}catch(t){n.scrollHeight}else n.selected=!1;return i||(t.selectedIndex=-1),s}}}}),pt.each(["radio","checkbox"],function(){pt.valHooks[this]={set:function(t,e){if(pt.isArray(e))return t.checked=pt.inArray(pt(t).val(),e)>-1}},ht.checkOn||(pt.valHooks[this].get=function(t){return null===t.getAttribute("value")?"on":t.value})});var xe,Re,Me=pt.expr.attrHandle,Oe=/^(?:checked|selected)$/i,Pe=ht.getSetAttribute,Ne=ht.input;pt.fn.extend({attr:function(t,e){return Ft(this,pt.attr,t,e,arguments.length>1)},removeAttr:function(t){return this.each(function(){pt.removeAttr(this,t)})}}),pt.extend({attr:function(t,e,i){var n,s,o=t.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof t.getAttribute?pt.prop(t,e,i):(1===o&&pt.isXMLDoc(t)||(e=e.toLowerCase(),s=pt.attrHooks[e]||(pt.expr.match.bool.test(e)?Re:xe)),void 0!==i?null===i?void pt.removeAttr(t,e):s&&"set"in s&&void 0!==(n=s.set(t,i,e))?n:(t.setAttribute(e,i+""),i):s&&"get"in s&&null!==(n=s.get(t,e))?n:(n=pt.find.attr(t,e),null==n?void 0:n))},attrHooks:{type:{set:function(t,e){if(!ht.radioValue&&"radio"===e&&pt.nodeName(t,"input")){var i=t.value;return t.setAttribute("type",e),i&&(t.value=i),e}}}},removeAttr:function(t,e){var i,n,s=0,o=e&&e.match(At);if(o&&1===t.nodeType)for(;i=o[s++];)n=pt.propFix[i]||i,pt.expr.match.bool.test(i)?Ne&&Pe||!Oe.test(i)?t[n]=!1:t[pt.camelCase("default-"+i)]=t[n]=!1:pt.attr(t,i,""),t.removeAttribute(Pe?i:n)}}),Re={set:function(t,e,i){return e===!1?pt.removeAttr(t,i):Ne&&Pe||!Oe.test(i)?t.setAttribute(!Pe&&pt.propFix[i]||i,i):t[pt.camelCase("default-"+i)]=t[i]=!0,i}},pt.each(pt.expr.match.bool.source.match(/\w+/g),function(t,e){var i=Me[e]||pt.find.attr;Ne&&Pe||!Oe.test(e)?Me[e]=function(t,e,n){var s,o;return n||(o=Me[e],Me[e]=s,s=null!=i(t,e,n)?e.toLowerCase():null,Me[e]=o),s}:Me[e]=function(t,e,i){if(!i)return t[pt.camelCase("default-"+e)]?e.toLowerCase():null}}),Ne&&Pe||(pt.attrHooks.value={set:function(t,e,i){return pt.nodeName(t,"input")?void(t.defaultValue=e):xe&&xe.set(t,e,i)}}),Pe||(xe={set:function(t,e,i){var n=t.getAttributeNode(i);if(n||t.setAttributeNode(n=t.ownerDocument.createAttribute(i)),n.value=e+="","value"===i||e===t.getAttribute(i))return e}},Me.id=Me.name=Me.coords=function(t,e,i){var n;if(!i)return(n=t.getAttributeNode(e))&&""!==n.value?n.value:null},pt.valHooks.button={get:function(t,e){var i=t.getAttributeNode(e);if(i&&i.specified)return i.value},set:xe.set},pt.attrHooks.contenteditable={set:function(t,e,i){xe.set(t,""!==e&&e,i)}},pt.each(["width","height"],function(t,e){pt.attrHooks[e]={set:function(t,i){if(""===i)return t.setAttribute(e,"auto"),i}}})),ht.style||(pt.attrHooks.style={get:function(t){return t.style.cssText||void 0},set:function(t,e){return t.style.cssText=e+""}});var $e=/^(?:input|select|textarea|button|object)$/i,Ue=/^(?:a|area)$/i;pt.fn.extend({prop:function(t,e){return Ft(this,pt.prop,t,e,arguments.length>1)},removeProp:function(t){return t=pt.propFix[t]||t,this.each(function(){try{this[t]=void 0,delete this[t]}catch(t){}})}}),pt.extend({prop:function(t,e,i){var n,s,o=t.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&pt.isXMLDoc(t)||(e=pt.propFix[e]||e,s=pt.propHooks[e]),void 0!==i?s&&"set"in s&&void 0!==(n=s.set(t,i,e))?n:t[e]=i:s&&"get"in s&&null!==(n=s.get(t,e))?n:t[e]},propHooks:{tabIndex:{get:function(t){var e=pt.find.attr(t,"tabindex");return e?parseInt(e,10):$e.test(t.nodeName)||Ue.test(t.nodeName)&&t.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),ht.hrefNormalized||pt.each(["href","src"],function(t,e){pt.propHooks[e]={get:function(t){return t.getAttribute(e,4)}}}),ht.optSelected||(pt.propHooks.selected={get:function(t){var e=t.parentNode;return e&&(e.selectedIndex,e.parentNode&&e.parentNode.selectedIndex),null},set:function(t){var e=t.parentNode;e&&(e.selectedIndex,e.parentNode&&e.parentNode.selectedIndex)}}),pt.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){pt.propFix[this.toLowerCase()]=this}),ht.enctype||(pt.propFix.enctype="encoding");var Fe=/[\t\r\n\f]/g;pt.fn.extend({addClass:function(t){var e,i,n,s,o,a,r,l=0;if(pt.isFunction(t))return this.each(function(e){pt(this).addClass(t.call(this,e,z(this)))});if("string"==typeof t&&t)for(e=t.match(At)||[];i=this[l++];)if(s=z(i),n=1===i.nodeType&&(" "+s+" ").replace(Fe," ")){for(a=0;o=e[a++];)n.indexOf(" "+o+" ")<0&&(n+=o+" ");r=pt.trim(n),s!==r&&pt.attr(i,"class",r)}return this},removeClass:function(t){var e,i,n,s,o,a,r,l=0;if(pt.isFunction(t))return this.each(function(e){pt(this).removeClass(t.call(this,e,z(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof t&&t)for(e=t.match(At)||[];i=this[l++];)if(s=z(i),n=1===i.nodeType&&(" "+s+" ").replace(Fe," ")){for(a=0;o=e[a++];)for(;n.indexOf(" "+o+" ")>-1;)n=n.replace(" "+o+" "," ");r=pt.trim(n),s!==r&&pt.attr(i,"class",r)}return this},toggleClass:function(t,e){var i=typeof t;return"boolean"==typeof e&&"string"===i?e?this.addClass(t):this.removeClass(t):pt.isFunction(t)?this.each(function(i){pt(this).toggleClass(t.call(this,i,z(this),e),e)}):this.each(function(){var e,n,s,o;if("string"===i)for(n=0,s=pt(this),o=t.match(At)||[];e=o[n++];)s.hasClass(e)?s.removeClass(e):s.addClass(e);else void 0!==t&&"boolean"!==i||(e=z(this),e&&pt._data(this,"__className__",e),pt.attr(this,"class",e||t===!1?"":pt._data(this,"__className__")||""))})},hasClass:function(t){var e,i,n=0;for(e=" "+t+" ";i=this[n++];)if(1===i.nodeType&&(" "+z(i)+" ").replace(Fe," ").indexOf(e)>-1)return!0;return!1}}),pt.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(t,e){pt.fn[e]=function(t,i){return arguments.length>0?this.on(e,null,t,i):this.trigger(e)}}),pt.fn.extend({hover:function(t,e){return this.mouseenter(t).mouseleave(e||t)}});var Be=t.location,He=pt.now(),je=/\?/,Ve=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;pt.parseJSON=function(e){if(t.JSON&&t.JSON.parse)return t.JSON.parse(e+"");var i,n=null,s=pt.trim(e+"");return s&&!pt.trim(s.replace(Ve,function(t,e,s,o){return i&&e&&(n=0),0===n?t:(i=s||e,n+=!o-!s,"")}))?Function("return "+s)():pt.error("Invalid JSON: "+e)},pt.parseXML=function(e){var i,n;if(!e||"string"!=typeof e)return null;try{t.DOMParser?(n=new t.DOMParser,i=n.parseFromString(e,"text/xml")):(i=new t.ActiveXObject("Microsoft.XMLDOM"),i.async="false",i.loadXML(e))}catch(t){i=void 0}return i&&i.documentElement&&!i.getElementsByTagName("parsererror").length||pt.error("Invalid XML: "+e),i};var ze=/#.*$/,Ge=/([?&])_=[^&]*/,We=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Ke=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Ye=/^(?:GET|HEAD)$/,qe=/^\/\//,Xe=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,Je={},Qe={},Ze="*/".concat("*"),ti=Be.href,ei=Xe.exec(ti.toLowerCase())||[];pt.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:ti,type:"GET",isLocal:Ke.test(ei[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Ze,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":pt.parseJSON,"text xml":pt.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(t,e){return e?K(K(t,pt.ajaxSettings),e):K(pt.ajaxSettings,t)},ajaxPrefilter:G(Je),ajaxTransport:G(Qe),ajax:function(e,i){function n(e,i,n,s){var o,h,b,S,E,L=i;2!==y&&(y=2,l&&t.clearTimeout(l),c=void 0,r=s||"",T.readyState=e>0?4:0,o=e>=200&&e<300||304===e,n&&(S=Y(u,T,n)),S=q(u,S,T,o),o?(u.ifModified&&(E=T.getResponseHeader("Last-Modified"),E&&(pt.lastModified[a]=E),E=T.getResponseHeader("etag"),E&&(pt.etag[a]=E)),204===e||"HEAD"===u.type?L="nocontent":304===e?L="notmodified":(L=S.state,h=S.data,b=S.error,o=!b)):(b=L,!e&&L||(L="error",e<0&&(e=0))),T.status=e,T.statusText=(i||L)+"",o?f.resolveWith(p,[h,L,T]):f.rejectWith(p,[T,L,b]),T.statusCode(v),v=void 0,d&&m.trigger(o?"ajaxSuccess":"ajaxError",[T,u,o?h:b]),g.fireWith(p,[T,L]),d&&(m.trigger("ajaxComplete",[T,u]),--pt.active||pt.event.trigger("ajaxStop")))}"object"==typeof e&&(i=e,e=void 0),i=i||{};var s,o,a,r,l,d,c,h,u=pt.ajaxSetup({},i),p=u.context||u,m=u.context&&(p.nodeType||p.jquery)?pt(p):pt.event,f=pt.Deferred(),g=pt.Callbacks("once memory"),v=u.statusCode||{},b={},S={},y=0,E="canceled",T={readyState:0,getResponseHeader:function(t){var e;if(2===y){if(!h)for(h={};e=We.exec(r);)h[e[1].toLowerCase()]=e[2];e=h[t.toLowerCase()]}return null==e?null:e},getAllResponseHeaders:function(){return 2===y?r:null},setRequestHeader:function(t,e){var i=t.toLowerCase();return y||(t=S[i]=S[i]||t,b[t]=e),this},overrideMimeType:function(t){return y||(u.mimeType=t),this},statusCode:function(t){var e;if(t)if(y<2)for(e in t)v[e]=[v[e],t[e]];else T.always(t[T.status]);return this},abort:function(t){var e=t||E;return c&&c.abort(e),n(0,e),this}};if(f.promise(T).complete=g.add,T.success=T.done,T.error=T.fail,u.url=((e||u.url||ti)+"").replace(ze,"").replace(qe,ei[1]+"//"),u.type=i.method||i.type||u.method||u.type,u.dataTypes=pt.trim(u.dataType||"*").toLowerCase().match(At)||[""],null==u.crossDomain&&(s=Xe.exec(u.url.toLowerCase()),u.crossDomain=!(!s||s[1]===ei[1]&&s[2]===ei[2]&&(s[3]||("http:"===s[1]?"80":"443"))===(ei[3]||("http:"===ei[1]?"80":"443")))),u.data&&u.processData&&"string"!=typeof u.data&&(u.data=pt.param(u.data,u.traditional)),W(Je,u,i,T),2===y)return T;d=pt.event&&u.global,d&&0===pt.active++&&pt.event.trigger("ajaxStart"),u.type=u.type.toUpperCase(),u.hasContent=!Ye.test(u.type),a=u.url,u.hasContent||(u.data&&(a=u.url+=(je.test(a)?"&":"?")+u.data,delete u.data),u.cache===!1&&(u.url=Ge.test(a)?a.replace(Ge,"$1_="+He++):a+(je.test(a)?"&":"?")+"_="+He++)),u.ifModified&&(pt.lastModified[a]&&T.setRequestHeader("If-Modified-Since",pt.lastModified[a]),pt.etag[a]&&T.setRequestHeader("If-None-Match",pt.etag[a])),(u.data&&u.hasContent&&u.contentType!==!1||i.contentType)&&T.setRequestHeader("Content-Type",u.contentType),T.setRequestHeader("Accept",u.dataTypes[0]&&u.accepts[u.dataTypes[0]]?u.accepts[u.dataTypes[0]]+("*"!==u.dataTypes[0]?", "+Ze+"; q=0.01":""):u.accepts["*"]);for(o in u.headers)T.setRequestHeader(o,u.headers[o]);if(u.beforeSend&&(u.beforeSend.call(p,T,u)===!1||2===y))return T.abort();E="abort";for(o in{success:1,error:1,complete:1})T[o](u[o]);if(c=W(Qe,u,i,T)){if(T.readyState=1,d&&m.trigger("ajaxSend",[T,u]),2===y)return T;u.async&&u.timeout>0&&(l=t.setTimeout(function(){T.abort("timeout")},u.timeout));try{y=1,c.send(b,n)}catch(t){if(!(y<2))throw t;n(-1,t)}}else n(-1,"No Transport");return T},getJSON:function(t,e,i){return pt.get(t,e,i,"json")},getScript:function(t,e){return pt.get(t,void 0,e,"script")}}),pt.each(["get","post"],function(t,e){pt[e]=function(t,i,n,s){return pt.isFunction(i)&&(s=s||n,n=i,i=void 0),pt.ajax(pt.extend({url:t,type:e,dataType:s,data:i,success:n},pt.isPlainObject(t)&&t))}}),pt._evalUrl=function(t){return pt.ajax({url:t,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},pt.fn.extend({wrapAll:function(t){if(pt.isFunction(t))return this.each(function(e){pt(this).wrapAll(t.call(this,e))});if(this[0]){var e=pt(t,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&e.insertBefore(this[0]),e.map(function(){for(var t=this;t.firstChild&&1===t.firstChild.nodeType;)t=t.firstChild;return t}).append(this)}return this},wrapInner:function(t){return pt.isFunction(t)?this.each(function(e){pt(this).wrapInner(t.call(this,e))}):this.each(function(){var e=pt(this),i=e.contents();i.length?i.wrapAll(t):e.append(t)})},wrap:function(t){var e=pt.isFunction(t);return this.each(function(i){pt(this).wrapAll(e?t.call(this,i):t)})},unwrap:function(){return this.parent().each(function(){pt.nodeName(this,"body")||pt(this).replaceWith(this.childNodes)}).end()}}),pt.expr.filters.hidden=function(t){return ht.reliableHiddenOffsets()?t.offsetWidth<=0&&t.offsetHeight<=0&&!t.getClientRects().length:J(t)},pt.expr.filters.visible=function(t){return!pt.expr.filters.hidden(t)};var ii=/%20/g,ni=/\[\]$/,si=/\r?\n/g,oi=/^(?:submit|button|image|reset|file)$/i,ai=/^(?:input|select|textarea|keygen)/i;pt.param=function(t,e){var i,n=[],s=function(t,e){e=pt.isFunction(e)?e():null==e?"":e,n[n.length]=encodeURIComponent(t)+"="+encodeURIComponent(e)};if(void 0===e&&(e=pt.ajaxSettings&&pt.ajaxSettings.traditional),pt.isArray(t)||t.jquery&&!pt.isPlainObject(t))pt.each(t,function(){s(this.name,this.value)});else for(i in t)Q(i,t[i],e,s);return n.join("&").replace(ii,"+")},pt.fn.extend({serialize:function(){return pt.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var t=pt.prop(this,"elements");return t?pt.makeArray(t):this}).filter(function(){var t=this.type;return this.name&&!pt(this).is(":disabled")&&ai.test(this.nodeName)&&!oi.test(t)&&(this.checked||!Bt.test(t))}).map(function(t,e){
var i=pt(this).val();return null==i?null:pt.isArray(i)?pt.map(i,function(t){return{name:e.name,value:t.replace(si,"\r\n")}}):{name:e.name,value:i.replace(si,"\r\n")}}).get()}}),pt.ajaxSettings.xhr=void 0!==t.ActiveXObject?function(){return this.isLocal?tt():nt.documentMode>8?Z():/^(get|post|head|put|delete|options)$/i.test(this.type)&&Z()||tt()}:Z;var ri=0,li={},di=pt.ajaxSettings.xhr();t.attachEvent&&t.attachEvent("onunload",function(){for(var t in li)li[t](void 0,!0)}),ht.cors=!!di&&"withCredentials"in di,di=ht.ajax=!!di,di&&pt.ajaxTransport(function(e){if(!e.crossDomain||ht.cors){var i;return{send:function(n,s){var o,a=e.xhr(),r=++ri;if(a.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(o in e.xhrFields)a[o]=e.xhrFields[o];e.mimeType&&a.overrideMimeType&&a.overrideMimeType(e.mimeType),e.crossDomain||n["X-Requested-With"]||(n["X-Requested-With"]="XMLHttpRequest");for(o in n)void 0!==n[o]&&a.setRequestHeader(o,n[o]+"");a.send(e.hasContent&&e.data||null),i=function(t,n){var o,l,d;if(i&&(n||4===a.readyState))if(delete li[r],i=void 0,a.onreadystatechange=pt.noop,n)4!==a.readyState&&a.abort();else{d={},o=a.status,"string"==typeof a.responseText&&(d.text=a.responseText);try{l=a.statusText}catch(t){l=""}o||!e.isLocal||e.crossDomain?1223===o&&(o=204):o=d.text?200:404}d&&s(o,l,d,a.getAllResponseHeaders())},e.async?4===a.readyState?t.setTimeout(i):a.onreadystatechange=li[r]=i:i()},abort:function(){i&&i(void 0,!0)}}}}),pt.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(t){return pt.globalEval(t),t}}}),pt.ajaxPrefilter("script",function(t){void 0===t.cache&&(t.cache=!1),t.crossDomain&&(t.type="GET",t.global=!1)}),pt.ajaxTransport("script",function(t){if(t.crossDomain){var e,i=nt.head||pt("head")[0]||nt.documentElement;return{send:function(n,s){e=nt.createElement("script"),e.async=!0,t.scriptCharset&&(e.charset=t.scriptCharset),e.src=t.url,e.onload=e.onreadystatechange=function(t,i){(i||!e.readyState||/loaded|complete/.test(e.readyState))&&(e.onload=e.onreadystatechange=null,e.parentNode&&e.parentNode.removeChild(e),e=null,i||s(200,"success"))},i.insertBefore(e,i.firstChild)},abort:function(){e&&e.onload(void 0,!0)}}}});var ci=[],hi=/(=)\?(?=&|$)|\?\?/;pt.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var t=ci.pop()||pt.expando+"_"+He++;return this[t]=!0,t}}),pt.ajaxPrefilter("json jsonp",function(e,i,n){var s,o,a,r=e.jsonp!==!1&&(hi.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&hi.test(e.data)&&"data");if(r||"jsonp"===e.dataTypes[0])return s=e.jsonpCallback=pt.isFunction(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,r?e[r]=e[r].replace(hi,"$1"+s):e.jsonp!==!1&&(e.url+=(je.test(e.url)?"&":"?")+e.jsonp+"="+s),e.converters["script json"]=function(){return a||pt.error(s+" was not called"),a[0]},e.dataTypes[0]="json",o=t[s],t[s]=function(){a=arguments},n.always(function(){void 0===o?pt(t).removeProp(s):t[s]=o,e[s]&&(e.jsonpCallback=i.jsonpCallback,ci.push(s)),a&&pt.isFunction(o)&&o(a[0]),a=o=void 0}),"script"}),pt.parseHTML=function(t,e,i){if(!t||"string"!=typeof t)return null;"boolean"==typeof e&&(i=e,e=!1),e=e||nt;var n=Tt.exec(t),s=!i&&[];return n?[e.createElement(n[1])]:(n=v([t],e,s),s&&s.length&&pt(s).remove(),pt.merge([],n.childNodes))};var ui=pt.fn.load;pt.fn.load=function(t,e,i){if("string"!=typeof t&&ui)return ui.apply(this,arguments);var n,s,o,a=this,r=t.indexOf(" ");return r>-1&&(n=pt.trim(t.slice(r,t.length)),t=t.slice(0,r)),pt.isFunction(e)?(i=e,e=void 0):e&&"object"==typeof e&&(s="POST"),a.length>0&&pt.ajax({url:t,type:s||"GET",dataType:"html",data:e}).done(function(t){o=arguments,a.html(n?pt("<div>").append(pt.parseHTML(t)).find(n):t)}).always(i&&function(t,e){a.each(function(){i.apply(this,o||[t.responseText,e,t])})}),this},pt.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(t,e){pt.fn[e]=function(t){return this.on(e,t)}}),pt.expr.filters.animated=function(t){return pt.grep(pt.timers,function(e){return t===e.elem}).length},pt.offset={setOffset:function(t,e,i){var n,s,o,a,r,l,d,c=pt.css(t,"position"),h=pt(t),u={};"static"===c&&(t.style.position="relative"),r=h.offset(),o=pt.css(t,"top"),l=pt.css(t,"left"),d=("absolute"===c||"fixed"===c)&&pt.inArray("auto",[o,l])>-1,d?(n=h.position(),a=n.top,s=n.left):(a=parseFloat(o)||0,s=parseFloat(l)||0),pt.isFunction(e)&&(e=e.call(t,i,pt.extend({},r))),null!=e.top&&(u.top=e.top-r.top+a),null!=e.left&&(u.left=e.left-r.left+s),"using"in e?e.using.call(t,u):h.css(u)}},pt.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){pt.offset.setOffset(this,t,e)});var e,i,n={top:0,left:0},s=this[0],o=s&&s.ownerDocument;if(o)return e=o.documentElement,pt.contains(e,s)?("undefined"!=typeof s.getBoundingClientRect&&(n=s.getBoundingClientRect()),i=et(o),{top:n.top+(i.pageYOffset||e.scrollTop)-(e.clientTop||0),left:n.left+(i.pageXOffset||e.scrollLeft)-(e.clientLeft||0)}):n},position:function(){if(this[0]){var t,e,i={top:0,left:0},n=this[0];return"fixed"===pt.css(n,"position")?e=n.getBoundingClientRect():(t=this.offsetParent(),e=this.offset(),pt.nodeName(t[0],"html")||(i=t.offset()),i.top+=pt.css(t[0],"borderTopWidth",!0),i.left+=pt.css(t[0],"borderLeftWidth",!0)),{top:e.top-i.top-pt.css(n,"marginTop",!0),left:e.left-i.left-pt.css(n,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent;t&&!pt.nodeName(t,"html")&&"static"===pt.css(t,"position");)t=t.offsetParent;return t||pe})}}),pt.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,e){var i=/Y/.test(e);pt.fn[t]=function(n){return Ft(this,function(t,n,s){var o=et(t);return void 0===s?o?e in o?o[e]:o.document.documentElement[n]:t[n]:void(o?o.scrollTo(i?pt(o).scrollLeft():s,i?s:pt(o).scrollTop()):t[n]=s)},t,n,arguments.length,null)}}),pt.each(["top","left"],function(t,e){pt.cssHooks[e]=x(ht.pixelPosition,function(t,i){if(i)return i=fe(t,e),he.test(i)?pt(t).position()[e]+"px":i})}),pt.each({Height:"height",Width:"width"},function(t,e){pt.each({padding:"inner"+t,content:e,"":"outer"+t},function(i,n){pt.fn[n]=function(n,s){var o=arguments.length&&(i||"boolean"!=typeof n),a=i||(n===!0||s===!0?"margin":"border");return Ft(this,function(e,i,n){var s;return pt.isWindow(e)?e.document.documentElement["client"+t]:9===e.nodeType?(s=e.documentElement,Math.max(e.body["scroll"+t],s["scroll"+t],e.body["offset"+t],s["offset"+t],s["client"+t])):void 0===n?pt.css(e,i,a):pt.style(e,i,n,a)},e,o?n:void 0,o,null)}})}),pt.fn.extend({bind:function(t,e,i){return this.on(t,null,e,i)},unbind:function(t,e){return this.off(t,null,e)},delegate:function(t,e,i,n){return this.on(e,t,i,n)},undelegate:function(t,e,i){return 1===arguments.length?this.off(t,"**"):this.off(e,t||"**",i)}}),pt.fn.size=function(){return this.length},pt.fn.andSelf=pt.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return pt});var pi=t.jQuery,mi=t.$;return pt.noConflict=function(e){return t.$===pt&&(t.$=mi),e&&t.jQuery===pt&&(t.jQuery=pi),pt},e||(t.jQuery=t.$=pt),pt}),function(t,e){"use strict";t.rails!==e&&t.error("jquery-ujs has already been loaded!");var i,n=t(document);t.rails=i={linkClickSelector:"a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]",buttonClickSelector:"button[data-remote]:not([form]):not(form button), button[data-confirm]:not([form]):not(form button)",inputChangeSelector:"select[data-remote], input[data-remote], textarea[data-remote]",formSubmitSelector:"form",formInputClickSelector:"form input[type=submit], form input[type=image], form button[type=submit], form button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])",disableSelector:"input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled",enableSelector:"input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled",requiredInputSelector:"input[name][required]:not([disabled]), textarea[name][required]:not([disabled])",fileInputSelector:"input[name][type=file]:not([disabled])",linkDisableSelector:"a[data-disable-with], a[data-disable]",buttonDisableSelector:"button[data-remote][data-disable-with], button[data-remote][data-disable]",csrfToken:function(){return t("meta[name=csrf-token]").attr("content")},csrfParam:function(){return t("meta[name=csrf-param]").attr("content")},CSRFProtection:function(t){var e=i.csrfToken();e&&t.setRequestHeader("X-CSRF-Token",e)},refreshCSRFTokens:function(){t('form input[name="'+i.csrfParam()+'"]').val(i.csrfToken())},fire:function(e,i,n){var s=t.Event(i);return e.trigger(s,n),s.result!==!1},confirm:function(t){return confirm(t)},ajax:function(e){return t.ajax(e)},href:function(t){return t[0].href},isRemote:function(t){return t.data("remote")!==e&&t.data("remote")!==!1},handleRemote:function(n){var s,o,a,r,l,d;if(i.fire(n,"ajax:before")){if(r=n.data("with-credentials")||null,l=n.data("type")||t.ajaxSettings&&t.ajaxSettings.dataType,n.is("form")){s=n.data("ujs:submit-button-formmethod")||n.attr("method"),o=n.data("ujs:submit-button-formaction")||n.attr("action"),a=t(n[0]).serializeArray();var c=n.data("ujs:submit-button");c&&(a.push(c),n.data("ujs:submit-button",null)),n.data("ujs:submit-button-formmethod",null),n.data("ujs:submit-button-formaction",null)}else n.is(i.inputChangeSelector)?(s=n.data("method"),o=n.data("url"),a=n.serialize(),n.data("params")&&(a=a+"&"+n.data("params"))):n.is(i.buttonClickSelector)?(s=n.data("method")||"get",o=n.data("url"),a=n.serialize(),n.data("params")&&(a=a+"&"+n.data("params"))):(s=n.data("method"),o=i.href(n),a=n.data("params")||null);return d={type:s||"GET",data:a,dataType:l,beforeSend:function(t,s){return s.dataType===e&&t.setRequestHeader("accept","*/*;q=0.5, "+s.accepts.script),!!i.fire(n,"ajax:beforeSend",[t,s])&&void n.trigger("ajax:send",t)},success:function(t,e,i){n.trigger("ajax:success",[t,e,i])},complete:function(t,e){n.trigger("ajax:complete",[t,e])},error:function(t,e,i){n.trigger("ajax:error",[t,e,i])},crossDomain:i.isCrossDomain(o)},r&&(d.xhrFields={withCredentials:r}),o&&(d.url=o),i.ajax(d)}return!1},isCrossDomain:function(t){var e=document.createElement("a");e.href=location.href;var i=document.createElement("a");try{return i.href=t,i.href=i.href,!((!i.protocol||":"===i.protocol)&&!i.host||e.protocol+"//"+e.host==i.protocol+"//"+i.host)}catch(t){return!0}},handleMethod:function(n){var s=i.href(n),o=n.data("method"),a=n.attr("target"),r=i.csrfToken(),l=i.csrfParam(),d=t('<form method="post" action="'+s+'"></form>'),c='<input name="_method" value="'+o+'" type="hidden" />';l===e||r===e||i.isCrossDomain(s)||(c+='<input name="'+l+'" value="'+r+'" type="hidden" />'),a&&d.attr("target",a),d.hide().append(c).appendTo("body"),d.submit()},formElements:function(e,i){return e.is("form")?t(e[0].elements).filter(i):e.find(i)},disableFormElements:function(e){i.formElements(e,i.disableSelector).each(function(){i.disableFormElement(t(this))})},disableFormElement:function(t){var i,n;i=t.is("button")?"html":"val",n=t.data("disable-with"),n!==e&&(t.data("ujs:enable-with",t[i]()),t[i](n)),t.prop("disabled",!0),t.data("ujs:disabled",!0)},enableFormElements:function(e){i.formElements(e,i.enableSelector).each(function(){i.enableFormElement(t(this))})},enableFormElement:function(t){var i=t.is("button")?"html":"val";t.data("ujs:enable-with")!==e&&(t[i](t.data("ujs:enable-with")),t.removeData("ujs:enable-with")),t.prop("disabled",!1),t.removeData("ujs:disabled")},allowAction:function(t){var e,n=t.data("confirm"),s=!1;if(!n)return!0;if(i.fire(t,"confirm")){try{s=i.confirm(n)}catch(t){(console.error||console.log).call(console,t.stack||t)}e=i.fire(t,"confirm:complete",[s])}return s&&e},blankInputs:function(e,i,n){var s,o,a,r,l=t(),d=i||"input,textarea",c=e.find(d),h={};return c.each(function(){s=t(this),s.is("input[type=radio]")?(r=s.attr("name"),h[r]||(0===e.find('input[type=radio]:checked[name="'+r+'"]').length&&(a=e.find('input[type=radio][name="'+r+'"]'),l=l.add(a)),h[r]=r)):(o=s.is("input[type=checkbox],input[type=radio]")?s.is(":checked"):!!s.val(),o===n&&(l=l.add(s)))}),!!l.length&&l},nonBlankInputs:function(t,e){return i.blankInputs(t,e,!0)},stopEverything:function(e){return t(e.target).trigger("ujs:everythingStopped"),e.stopImmediatePropagation(),!1},disableElement:function(t){var n=t.data("disable-with");n!==e&&(t.data("ujs:enable-with",t.html()),t.html(n)),t.bind("click.railsDisable",function(t){return i.stopEverything(t)}),t.data("ujs:disabled",!0)},enableElement:function(t){t.data("ujs:enable-with")!==e&&(t.html(t.data("ujs:enable-with")),t.removeData("ujs:enable-with")),t.unbind("click.railsDisable"),t.removeData("ujs:disabled")}},i.fire(n,"rails:attachBindings")&&(t.ajaxPrefilter(function(t,e,n){t.crossDomain||i.CSRFProtection(n)}),t(window).on("pageshow.rails",function(){t(t.rails.enableSelector).each(function(){var e=t(this);e.data("ujs:disabled")&&t.rails.enableFormElement(e)}),t(t.rails.linkDisableSelector).each(function(){var e=t(this);e.data("ujs:disabled")&&t.rails.enableElement(e)})}),n.on("ajax:complete",i.linkDisableSelector,function(){i.enableElement(t(this))}),n.on("ajax:complete",i.buttonDisableSelector,function(){i.enableFormElement(t(this))}),n.on("click.rails",i.linkClickSelector,function(e){var n=t(this),s=n.data("method"),o=n.data("params"),a=e.metaKey||e.ctrlKey;if(!i.allowAction(n))return i.stopEverything(e);if(!a&&n.is(i.linkDisableSelector)&&i.disableElement(n),i.isRemote(n)){if(a&&(!s||"GET"===s)&&!o)return!0;var r=i.handleRemote(n);return r===!1?i.enableElement(n):r.fail(function(){i.enableElement(n)}),!1}return s?(i.handleMethod(n),!1):void 0}),n.on("click.rails",i.buttonClickSelector,function(e){var n=t(this);if(!i.allowAction(n)||!i.isRemote(n))return i.stopEverything(e);n.is(i.buttonDisableSelector)&&i.disableFormElement(n);var s=i.handleRemote(n);return s===!1?i.enableFormElement(n):s.fail(function(){i.enableFormElement(n)}),!1}),n.on("change.rails",i.inputChangeSelector,function(e){var n=t(this);return i.allowAction(n)&&i.isRemote(n)?(i.handleRemote(n),!1):i.stopEverything(e)}),n.on("submit.rails",i.formSubmitSelector,function(n){var s,o,a=t(this),r=i.isRemote(a);if(!i.allowAction(a))return i.stopEverything(n);if(a.attr("novalidate")===e)if(a.data("ujs:formnovalidate-button")===e){if(s=i.blankInputs(a,i.requiredInputSelector,!1),s&&i.fire(a,"ajax:aborted:required",[s]))return i.stopEverything(n)}else a.data("ujs:formnovalidate-button",e);if(r){if(o=i.nonBlankInputs(a,i.fileInputSelector)){setTimeout(function(){i.disableFormElements(a)},13);var l=i.fire(a,"ajax:aborted:file",[o]);return l||setTimeout(function(){i.enableFormElements(a)},13),l}return i.handleRemote(a),!1}setTimeout(function(){i.disableFormElements(a)},13)}),n.on("click.rails",i.formInputClickSelector,function(e){var n=t(this);if(!i.allowAction(n))return i.stopEverything(e);var s=n.attr("name"),o=s?{name:s,value:n.val()}:null,a=n.closest("form");0===a.length&&(a=t("#"+n.attr("form"))),a.data("ujs:submit-button",o),a.data("ujs:formnovalidate-button",n.attr("formnovalidate")),a.data("ujs:submit-button-formaction",n.attr("formaction")),a.data("ujs:submit-button-formmethod",n.attr("formmethod"))}),n.on("ajax:send.rails",i.formSubmitSelector,function(e){this===e.target&&i.disableFormElements(t(this))}),n.on("ajax:complete.rails",i.formSubmitSelector,function(e){this===e.target&&i.enableFormElements(t(this))}),t(function(){i.refreshCSRFTokens()}))}(jQuery),function(t){t.extend({debounce:function(t,e,i,n){3==arguments.length&&"boolean"!=typeof i&&(n=i,i=!1);var s;return function(){var o=arguments;n=n||this,i&&!s&&t.apply(n,o),clearTimeout(s),s=setTimeout(function(){i||t.apply(n,o),s=null},e)}},throttle:function(t,e,i){var n,s,o;return function(){s=arguments,o=!0,i=i||this,n||function(){o?(t.apply(i,s),o=!1,n=setTimeout(arguments.callee,e)):n=null}()}}})}(jQuery),jQuery.easing.jswing=jQuery.easing.swing,jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(t,e,i,n,s){return jQuery.easing[jQuery.easing.def](t,e,i,n,s)},easeInQuad:function(t,e,i,n,s){return n*(e/=s)*e+i},easeOutQuad:function(t,e,i,n,s){return-n*(e/=s)*(e-2)+i},easeInOutQuad:function(t,e,i,n,s){return(e/=s/2)<1?n/2*e*e+i:-n/2*(--e*(e-2)-1)+i},easeInCubic:function(t,e,i,n,s){return n*(e/=s)*e*e+i},easeOutCubic:function(t,e,i,n,s){return n*((e=e/s-1)*e*e+1)+i},easeInOutCubic:function(t,e,i,n,s){return(e/=s/2)<1?n/2*e*e*e+i:n/2*((e-=2)*e*e+2)+i},easeInQuart:function(t,e,i,n,s){return n*(e/=s)*e*e*e+i},easeOutQuart:function(t,e,i,n,s){return-n*((e=e/s-1)*e*e*e-1)+i},easeInOutQuart:function(t,e,i,n,s){return(e/=s/2)<1?n/2*e*e*e*e+i:-n/2*((e-=2)*e*e*e-2)+i},easeInQuint:function(t,e,i,n,s){return n*(e/=s)*e*e*e*e+i},easeOutQuint:function(t,e,i,n,s){return n*((e=e/s-1)*e*e*e*e+1)+i},easeInOutQuint:function(t,e,i,n,s){return(e/=s/2)<1?n/2*e*e*e*e*e+i:n/2*((e-=2)*e*e*e*e+2)+i},easeInSine:function(t,e,i,n,s){return-n*Math.cos(e/s*(Math.PI/2))+n+i},easeOutSine:function(t,e,i,n,s){return n*Math.sin(e/s*(Math.PI/2))+i},easeInOutSine:function(t,e,i,n,s){return-n/2*(Math.cos(Math.PI*e/s)-1)+i},easeInExpo:function(t,e,i,n,s){return 0==e?i:n*Math.pow(2,10*(e/s-1))+i},easeOutExpo:function(t,e,i,n,s){return e==s?i+n:n*(-Math.pow(2,-10*e/s)+1)+i},easeInOutExpo:function(t,e,i,n,s){return 0==e?i:e==s?i+n:(e/=s/2)<1?n/2*Math.pow(2,10*(e-1))+i:n/2*(-Math.pow(2,-10*--e)+2)+i},easeInCirc:function(t,e,i,n,s){return-n*(Math.sqrt(1-(e/=s)*e)-1)+i},easeOutCirc:function(t,e,i,n,s){return n*Math.sqrt(1-(e=e/s-1)*e)+i},easeInOutCirc:function(t,e,i,n,s){return(e/=s/2)<1?-n/2*(Math.sqrt(1-e*e)-1)+i:n/2*(Math.sqrt(1-(e-=2)*e)+1)+i},easeInElastic:function(t,e,i,n,s){var o=1.70158,a=0,r=n;if(0==e)return i;if(1==(e/=s))return i+n;if(a||(a=.3*s),r<Math.abs(n)){r=n;var o=a/4}else var o=a/(2*Math.PI)*Math.asin(n/r);return-(r*Math.pow(2,10*(e-=1))*Math.sin((e*s-o)*(2*Math.PI)/a))+i},easeOutElastic:function(t,e,i,n,s){var o=1.70158,a=0,r=n;if(0==e)return i;if(1==(e/=s))return i+n;if(a||(a=.3*s),r<Math.abs(n)){r=n;var o=a/4}else var o=a/(2*Math.PI)*Math.asin(n/r);return r*Math.pow(2,-10*e)*Math.sin((e*s-o)*(2*Math.PI)/a)+n+i},easeInOutElastic:function(t,e,i,n,s){var o=1.70158,a=0,r=n;if(0==e)return i;if(2==(e/=s/2))return i+n;if(a||(a=s*(.3*1.5)),r<Math.abs(n)){r=n;var o=a/4}else var o=a/(2*Math.PI)*Math.asin(n/r);return e<1?-.5*(r*Math.pow(2,10*(e-=1))*Math.sin((e*s-o)*(2*Math.PI)/a))+i:r*Math.pow(2,-10*(e-=1))*Math.sin((e*s-o)*(2*Math.PI)/a)*.5+n+i},easeInBack:function(t,e,i,n,s,o){return void 0==o&&(o=1.70158),n*(e/=s)*e*((o+1)*e-o)+i},easeOutBack:function(t,e,i,n,s,o){return void 0==o&&(o=1.70158),n*((e=e/s-1)*e*((o+1)*e+o)+1)+i},easeInOutBack:function(t,e,i,n,s,o){return void 0==o&&(o=1.70158),(e/=s/2)<1?n/2*(e*e*(((o*=1.525)+1)*e-o))+i:n/2*((e-=2)*e*(((o*=1.525)+1)*e+o)+2)+i},easeInBounce:function(t,e,i,n,s){return n-jQuery.easing.easeOutBounce(t,s-e,0,n,s)+i},easeOutBounce:function(t,e,i,n,s){return(e/=s)<1/2.75?n*(7.5625*e*e)+i:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+i:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+i:n*(7.5625*(e-=2.625/2.75)*e+.984375)+i},easeInOutBounce:function(t,e,i,n,s){return e<s/2?.5*jQuery.easing.easeInBounce(t,2*e,0,n,s)+i:.5*jQuery.easing.easeOutBounce(t,2*e-s,0,n,s)+.5*n+i}}),function(){var t,e,i,n,s,o,a,r,l,d,c,h,u,p,m,f,g,v,b,S=[].slice,y=[].indexOf||function(t){for(var e=0,i=this.length;e<i;e++)if(e in this&&this[e]===t)return e;return-1};t=jQuery,t.payment={},t.payment.fn={},t.fn.payment=function(){var e,i;return i=arguments[0],e=2<=arguments.length?S.call(arguments,1):[],t.payment.fn[i].apply(this,e)},s=/(\d{1,4})/g,n=[{type:"maestro",pattern:/^(5018|5020|5038|6304|6759|676[1-3])/,format:s,length:[12,13,14,15,16,17,18,19],cvcLength:[3],luhn:!0},{type:"dinersclub",pattern:/^(36|38|30[0-5])/,format:s,length:[14],cvcLength:[3],luhn:!0},{type:"laser",pattern:/^(6706|6771|6709)/,format:s,length:[16,17,18,19],cvcLength:[3],luhn:!0},{type:"jcb",pattern:/^35/,format:s,length:[16],cvcLength:[3],luhn:!0},{type:"unionpay",pattern:/^62/,format:s,length:[16,17,18,19],cvcLength:[3],luhn:!1},{type:"discover",pattern:/^(6011|65|64[4-9]|622)/,format:s,length:[16],cvcLength:[3],luhn:!0},{type:"mastercard",pattern:/^5[1-5]/,format:s,length:[16],cvcLength:[3],luhn:!0},{type:"amex",pattern:/^3[47]/,format:/(\d{1,4})(\d{1,6})?(\d{1,5})?/,length:[15],cvcLength:[3,4],luhn:!0},{type:"visa",pattern:/^4/,format:s,length:[13,14,15,16],cvcLength:[3],luhn:!0}],e=function(t){var e,i,s;for(t=(t+"").replace(/\D/g,""),i=0,s=n.length;i<s;i++)if(e=n[i],e.pattern.test(t))return e},i=function(t){var e,i,s;for(i=0,s=n.length;i<s;i++)if(e=n[i],e.type===t)return e},u=function(t){var e,i,n,s,o,a;for(n=!0,s=0,i=(t+"").split("").reverse(),o=0,a=i.length;o<a;o++)e=i[o],e=parseInt(e,10),(n=!n)&&(e*=2),e>9&&(e-=9),s+=e;return s%10===0},h=function(t){var e;return null!=t.prop("selectionStart")&&t.prop("selectionStart")!==t.prop("selectionEnd")||!("undefined"==typeof document||null===document||null==(e=document.selection)||"function"!=typeof e.createRange||!e.createRange().text)},p=function(e){return setTimeout(function(){var i,n;return i=t(e.currentTarget),n=i.val(),n=t.payment.formatCardNumber(n),i.val(n)})},r=function(i){var n,s,o,a,r,l,d;if(o=String.fromCharCode(i.which),/^\d+$/.test(o)&&(n=t(i.currentTarget),d=n.val(),s=e(d+o),a=(d.replace(/\D/g,"")+o).length,l=16,s&&(l=s.length[s.length.length-1]),!(a>=l||null!=n.prop("selectionStart")&&n.prop("selectionStart")!==d.length)))return r=s&&"amex"===s.type?/^(\d{4}|\d{4}\s\d{6})$/:/(?:^|\s)(\d{4})$/,r.test(d)?(i.preventDefault(),n.val(d+" "+o)):r.test(d+o)?(i.preventDefault(),n.val(d+o+" ")):void 0},o=function(e){var i,n;if(i=t(e.currentTarget),n=i.val(),!e.meta&&(null==i.prop("selectionStart")||i.prop("selectionStart")===n.length))return 8===e.which&&/\s\d?$/.test(n)?(e.preventDefault(),i.val(n.replace(/\s\d?$/,""))):void 0},l=function(e){var i,n,s;if(n=String.fromCharCode(e.which),/^\d+$/.test(n))return i=t(e.currentTarget),s=i.val()+n,/^\d$/.test(s)&&"0"!==s&&"1"!==s?(e.preventDefault(),i.val("0"+s+" / ")):/^\d\d$/.test(s)?(e.preventDefault(),i.val(""+s+" / ")):void 0},d=function(e){var i,n,s;if(n=String.fromCharCode(e.which),/^\d+$/.test(n))return i=t(e.currentTarget),s=i.val(),/^\d\d$/.test(s)?i.val(""+s+" / "):void 0},c=function(e){var i,n,s;if(n=String.fromCharCode(e.which),"/"===n)return i=t(e.currentTarget),s=i.val(),/^\d$/.test(s)&&"0"!==s?i.val("0"+s+" / "):void 0},a=function(e){var i,n;if(!e.meta&&(i=t(e.currentTarget),n=i.val(),8===e.which&&(null==i.prop("selectionStart")||i.prop("selectionStart")===n.length)))return/\s\/\s?\d?$/.test(n)?(e.preventDefault(),i.val(n.replace(/\s\/\s?\d?$/,""))):void 0},v=function(t){var e;return!(!t.metaKey&&!t.ctrlKey)||32!==t.which&&(0===t.which||(t.which<33||(e=String.fromCharCode(t.which),!!/[\d\s]/.test(e))))},f=function(i){var n,s,o,a;if(n=t(i.currentTarget),o=String.fromCharCode(i.which),/^\d+$/.test(o)&&!h(n))return a=(n.val()+o).replace(/\D/g,""),s=e(a),s?a.length<=s.length[s.length.length-1]:a.length<=16},g=function(e){var i,n,s;if(i=t(e.currentTarget),n=String.fromCharCode(e.which),/^\d+$/.test(n)&&!h(i))return s=i.val()+n,s=s.replace(/\D/g,""),!(s.length>6)&&void 0},m=function(e){var i,n,s;if(i=t(e.currentTarget),n=String.fromCharCode(e.which),/^\d+$/.test(n))return s=i.val()+n,s.length<=4},b=function(e){var i,s,o,a,r;if(i=t(e.currentTarget),r=i.val(),a=t.payment.cardType(r)||"unknown",!i.hasClass(a))return s=function(){var t,e,i;for(i=[],t=0,e=n.length;t<e;t++)o=n[t],i.push(o.type);return i}(),i.removeClass("unknown"),i.removeClass(s.join(" ")),i.addClass(a),i.toggleClass("identified","unknown"!==a),i.trigger("payment.cardType",a)},t.payment.fn.formatCardCVC=function(){return this.payment("restrictNumeric"),this.on("keypress",m),this},t.payment.fn.formatCardExpiry=function(){return this.payment("restrictNumeric"),this.on("keypress",g),this.on("keypress",l),this.on("keypress",c),this.on("keypress",d),this.on("keydown",a),this},t.payment.fn.formatCardNumber=function(){return this.payment("restrictNumeric"),this.on("keypress",f),this.on("keypress",r),this.on("keydown",o),this.on("keyup",b),this.on("paste",p),this},t.payment.fn.restrictNumeric=function(){return this.on("keypress",v),this},t.payment.fn.cardExpiryVal=function(){return t.payment.cardExpiryVal(t(this).val())},t.payment.cardExpiryVal=function(t){var e,i,n,s;return t=t.replace(/\s/g,""),s=t.split("/",2),e=s[0],n=s[1],2===(null!=n?n.length:void 0)&&/^\d+$/.test(n)&&(i=(new Date).getFullYear(),i=i.toString().slice(0,2),n=i+n),e=parseInt(e,10),n=parseInt(n,10),{month:e,year:n}},t.payment.validateCardNumber=function(t){var i,n;return t=(t+"").replace(/\s+|-/g,""),!!/^\d+$/.test(t)&&(i=e(t),!!i&&(n=t.length,y.call(i.length,n)>=0&&(i.luhn===!1||u(t))))},t.payment.validateCardExpiry=function(e,i){var n,s,o,a;return"object"==typeof e&&"month"in e&&(a=e,e=a.month,i=a.year),!(!e||!i)&&(e=t.trim(e),i=t.trim(i),!!/^\d+$/.test(e)&&(!!/^\d+$/.test(i)&&(parseInt(e,10)<=12&&(2===i.length&&(o=(new Date).getFullYear(),o=o.toString().slice(0,2),i=o+i),s=new Date(i,e),n=new Date,s.setMonth(s.getMonth()-1),s.setMonth(s.getMonth()+1,1),s>n))))},t.payment.validateCardCVC=function(e,n){var s,o;return e=t.trim(e),!!/^\d+$/.test(e)&&(n?(s=e.length,y.call(null!=(o=i(n))?o.cvcLength:void 0,s)>=0):e.length>=3&&e.length<=4)},t.payment.cardType=function(t){var i;return t?(null!=(i=e(t))?i.type:void 0)||null:null},t.payment.formatCardNumber=function(t){var i,n,s,o;return(i=e(t))?(s=i.length[i.length.length-1],t=t.replace(/\D/g,""),t=t.slice(0,+s+1||9e9),i.format.global?null!=(o=t.match(i.format))?o.join(" "):void 0:(n=i.format.exec(t),null!=n&&n.shift(),null!=n?n.join(" "):void 0)):t}}.call(this),function(t){t.fn.changeElementType=function(e){this.each(function(i,n){var s={};t.each(n.attributes,function(t,e){s[e.nodeName]=e.nodeValue});var o=t("<"+e+"/>",s).append(t(n).contents());return t(n).replaceWith(o),o})}}(jQuery),function(t,e,i){"function"==typeof define&&define.amd?define(["jquery"],function(n){return i(n,t,e),n.mobile}):i(t.jQuery,t,e)}(this,document,function(t,e,i){!function(t,e,i,n){function s(t){for(;t&&"undefined"!=typeof t.originalEvent;)t=t.originalEvent;return t}function o(e,i){var o,a,r,l,d,c,h,u,p,m=e.type;if(e=t.Event(e),e.type=i,o=e.originalEvent,a=t.event.props,m.search(/^(mouse|click)/)>-1&&(a=I),o)for(h=a.length,l;h;)l=a[--h],e[l]=o[l];if(m.search(/mouse(down|up)|click/)>-1&&!e.which&&(e.which=1),m.search(/^touch/)!==-1&&(r=s(o),m=r.touches,d=r.changedTouches,c=m&&m.length?m[0]:d&&d.length?d[0]:n))for(u=0,p=D.length;u<p;u++)l=D[u],e[l]=c[l];return e}function a(e){for(var i,n,s={};e;){i=t.data(e,w);for(n in i)i[n]&&(s[n]=s.hasVirtualBinding=!0);e=e.parentNode}return s}function r(e,i){for(var n;e;){if(n=t.data(e,w),n&&(!i||n[i]))return e;e=e.parentNode}return null}function l(){U=!1}function d(){U=!0}function c(){j=0,N.length=0,$=!1,d()}function h(){l()}function u(){p(),R=setTimeout(function(){R=0,c()},t.vmouse.resetTimerDuration)}function p(){R&&(clearTimeout(R),R=0)}function m(e,i,n){var s;return(n&&n[e]||!n&&r(i.target,e))&&(s=o(i,e),t(i.target).trigger(s)),s}function f(e){var i,n=t.data(e.target,C);$||j&&j===n||(i=m("v"+e.type,e),i&&(i.isDefaultPrevented()&&e.preventDefault(),i.isPropagationStopped()&&e.stopPropagation(),i.isImmediatePropagationStopped()&&e.stopImmediatePropagation()))}function g(e){var i,n,o,r=s(e).touches;r&&1===r.length&&(i=e.target,n=a(i),n.hasVirtualBinding&&(j=H++,t.data(i,C,j),p(),h(),P=!1,o=s(e).touches[0],M=o.pageX,O=o.pageY,m("vmouseover",e,n),m("vmousedown",e,n)))}function v(t){U||(P||m("vmousecancel",t,a(t.target)),P=!0,u())}function b(e){if(!U){var i=s(e).touches[0],n=P,o=t.vmouse.moveDistanceThreshold,r=a(e.target);P=P||Math.abs(i.pageX-M)>o||Math.abs(i.pageY-O)>o,P&&!n&&m("vmousecancel",e,r),m("vmousemove",e,r),u()}}function S(t){if(!U){d();var e,i,n=a(t.target);m("vmouseup",t,n),P||(e=m("vclick",t,n),e&&e.isDefaultPrevented()&&(i=s(t).changedTouches[0],N.push({touchID:j,x:i.clientX,y:i.clientY}),$=!0)),m("vmouseout",t,n),P=!1,u()}}function y(e){var i,n=t.data(e,w);if(n)for(i in n)if(n[i])return!0;return!1}function E(){}function T(e){var i=e.substr(1);return{setup:function(){y(this)||t.data(this,w,{});var n=t.data(this,w);n[e]=!0,x[e]=(x[e]||0)+1,1===x[e]&&B.bind(i,f),t(this).bind(i,E),F&&(x.touchstart=(x.touchstart||0)+1,1===x.touchstart&&B.bind("touchstart",g).bind("touchend",S).bind("touchmove",b).bind("scroll",v))},teardown:function(){--x[e],x[e]||B.unbind(i,f),F&&(--x.touchstart,x.touchstart||B.unbind("touchstart",g).unbind("touchmove",b).unbind("touchend",S).unbind("scroll",v));var n=t(this),s=t.data(this,w);s&&(s[e]=!1),n.unbind(i,E),y(this)||n.removeData(w)}}}var L,k,w="virtualMouseBindings",C="virtualTouchID",_="vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split(" "),D="clientX clientY pageX pageY screenX screenY".split(" "),A=t.event.mouseHooks?t.event.mouseHooks.props:[],I=t.event.props.concat(A),x={},R=0,M=0,O=0,P=!1,N=[],$=!1,U=!1,F="addEventListener"in i,B=t(i),H=1,j=0;for(t.vmouse={moveDistanceThreshold:10,clickDistanceThreshold:10,resetTimerDuration:1500},k=0;k<_.length;k++)t.event.special[_[k]]=T(_[k]);F&&i.addEventListener("click",function(e){var i,n,s,o,a,r,l=N.length,d=e.target;if(l)for(i=e.clientX,n=e.clientY,L=t.vmouse.clickDistanceThreshold,s=d;s;){for(o=0;o<l;o++)if(a=N[o],r=0,s===d&&Math.abs(a.x-i)<L&&Math.abs(a.y-n)<L||t.data(s,C)===a.touchID)return e.preventDefault(),void e.stopPropagation();s=s.parentNode}},!0)}(t,e,i)}),jQuery.extend({highlight:function(t,e,i,n){if(3===t.nodeType){var s=t.data.match(e);if(s){var o=document.createElement(i||"span");o.className=n||"highlight";var a=t.splitText(s.index);a.splitText(s[0].length);var r=a.cloneNode(!0);return o.appendChild(r),a.parentNode.replaceChild(o,a),1}}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&(t.tagName!==i.toUpperCase()||t.className!==n))for(var l=0;l<t.childNodes.length;l++)l+=jQuery.highlight(t.childNodes[l],e,i,n);return 0}}),jQuery.fn.unhighlight=function(t){var e={className:"highlight",element:"span"};return jQuery.extend(e,t),this.find(e.element+"."+e.className).each(function(){var t=this.parentNode;t.replaceChild(this.firstChild,this),t.normalize()}).end()},jQuery.fn.highlight=function(t,e){var i={className:"highlight",element:"span",caseSensitive:!1,wordsOnly:!1};if(jQuery.extend(i,e),t.constructor===String&&(t=[t]),t=jQuery.grep(t,function(t){return""!=t}),t=jQuery.map(t,function(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}),0==t.length)return this;var n=i.caseSensitive?"":"i",s="("+t.join("|")+")";i.wordsOnly&&(s="\\b"+s+"\\b");var o=new RegExp(s,n);return this.each(function(){jQuery.highlight(this,o,i.element,i.className)})},function(){var t=!1,e=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.Class=function(){},Class.extend=function(i){function n(){!t&&this.init&&this.init.apply(this,arguments)}var s=this.prototype;t=!0;var o=new this;t=!1;for(var a in i)o[a]="function"==typeof i[a]&&"function"==typeof s[a]&&e.test(i[a])?function(t,e){return function(){var i=this._super;this._super=s[t];var n=e.apply(this,arguments);return this._super=i,n}}(a,i[a]):i[a];return n.prototype=o,n.constructor=n,n.extend=arguments.callee,n}}(),function(t){"function"==typeof define?define(function(){t()}):t()}(function(t){if(!Function.prototype.bind){var e=Array.prototype.slice;Function.prototype.bind=function(){function t(){if(this instanceof t){var s=Object.create(i.prototype);return i.apply(s,n.concat(e.call(arguments))),s}return i.call.apply(i,n.concat(e.call(arguments)))}var i=this;if("function"!=typeof i.apply||"function"!=typeof i.call)return new TypeError;var n=e.call(arguments);return t.length="function"==typeof i?Math.max(i.length-n.length,0):0,t}}var i,n,s,o,a,r=Function.prototype.call,l=Object.prototype,d=r.bind(l.hasOwnProperty);(a=d(l,"__defineGetter__"))&&(i=r.bind(l.__defineGetter__),n=r.bind(l.__defineSetter__),s=r.bind(l.__lookupGetter__),o=r.bind(l.__lookupSetter__)),Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Array.prototype.forEach||(Array.prototype.forEach=function(t,e){for(var i=+this.length,n=0;n<i;n++)n in this&&t.call(e,this[n],n,this)}),Array.prototype.map||(Array.prototype.map=function(t,e){var i=+this.length;if("function"!=typeof t)throw new TypeError;for(var n=Array(i),s=0;s<i;s++)s in this&&(n[s]=t.call(e,this[s],s,this));
return n}),Array.prototype.filter||(Array.prototype.filter=function(t,e){for(var i=[],n=0;n<this.length;n++)t.call(e,this[n])&&i.push(this[n]);return i}),Array.prototype.every||(Array.prototype.every=function(t,e){for(var i=0;i<this.length;i++)if(!t.call(e,this[i]))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(t,e){for(var i=0;i<this.length;i++)if(t.call(e,this[i]))return!0;return!1}),Array.prototype.reduce||(Array.prototype.reduce=function(t){var e=+this.length;if("function"!=typeof t)throw new TypeError;if(0===e&&1===arguments.length)throw new TypeError;var i=0;if(arguments.length>=2)var n=arguments[1];else for(;;){if(i in this){n=this[i++];break}if(++i>=e)throw new TypeError}for(;i<e;i++)i in this&&(n=t.call(null,n,this[i],i,this));return n}),Array.prototype.reduceRight||(Array.prototype.reduceRight=function(t){var e=+this.length;if("function"!=typeof t)throw new TypeError;if(0===e&&1===arguments.length)throw new TypeError;var i;if(e-=1,arguments.length>=2)i=arguments[1];else for(;;){if(e in this){i=this[e--];break}if(--e<0)throw new TypeError}for(;e>=0;e--)e in this&&(i=t.call(null,i,this[e],e,this));return i}),Array.prototype.indexOf||(Array.prototype.indexOf=function(t,e){var i=this.length;if(!i)return-1;var n=e||0;if(n>=i)return-1;for(n<0&&(n+=i);n<i;n++)if(n in this&&t===this[n])return n;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(t,e){var i=this.length;if(!i)return-1;var n=e||i;for(n<0&&(n+=i),n=Math.min(n,i-1);n>=0;n--)if(n in this&&t===this[n])return n;return-1}),Object.getPrototypeOf||(Object.getPrototypeOf=function(t){return t.__proto__||t.constructor.prototype}),Object.getOwnPropertyDescriptor||(Object.getOwnPropertyDescriptor=function(e,i){if("object"!=typeof e&&"function"!=typeof e||null===e)throw new TypeError("Object.getOwnPropertyDescriptor called on a non-object: "+e);if(!d(e,i))return t;var n,r,c;if(n={enumerable:!0,configurable:!0},a){var h=e.__proto__;if(e.__proto__=l,r=s(e,i),c=o(e,i),e.__proto__=h,r||c)return r&&(n.get=r),c&&(n.set=c),n}return n.value=e[i],n}),Object.getOwnPropertyNames||(Object.getOwnPropertyNames=function(t){return Object.keys(t)}),Object.create||(Object.create=function(t,e){var i;if(null===t)i={__proto__:null};else{if("object"!=typeof t)throw new TypeError("typeof prototype["+typeof t+"] != 'object'");i=function(){},i.prototype=t,i=new i,i.__proto__=t}return"undefined"!=typeof e&&Object.defineProperties(i,e),i}),Object.defineProperty||(Object.defineProperty=function(t,e,r){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object.defineProperty called on non-object: "+t);if("object"!=typeof r||null===r)throw new TypeError("Property description must be an object: "+r);if(d(r,"value"))a&&(s(t,e)||o(t,e))&&(t.__proto__=l,delete t[e]),t[e]=r.value;else{if(!a)throw new TypeError("getters & setters can not be defined on this javascript engine");d(r,"get")&&i(t,e,r.get),d(r,"set")&&n(t,e,r.set)}return t}),Object.defineProperties||(Object.defineProperties=function(t,e){for(var i in e)d(e,i)&&Object.defineProperty(t,i,e[i]);return t}),Object.seal||(Object.seal=function(t){return t}),Object.freeze||(Object.freeze=function(t){return t});try{Object.freeze(function(){})}catch(t){Object.freeze=function(t){return function(e){return"function"==typeof e?e:t(e)}}(Object.freeze)}if(Object.preventExtensions||(Object.preventExtensions=function(t){return t}),Object.isSealed||(Object.isSealed=function(){return!1}),Object.isFrozen||(Object.isFrozen=function(){return!1}),Object.isExtensible||(Object.isExtensible=function(){return!0}),!Object.keys){var c,h=!0,u=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],p=u.length;for(c in{toString:null})h=!1;Object.keys=function t(e){if("object"!=typeof e&&"function"!=typeof e||null===e)throw new TypeError("Object.keys called on a non-object");var i,t=[];for(i in e)d(e,i)&&t.push(i);if(h)for(i=0;i<p;i++){var n=u[i];d(e,n)&&t.push(n)}return t}}if(Date.prototype.toISOString||(Date.prototype.toISOString=function(){return this.getUTCFullYear()+"-"+(this.getUTCMonth()+1)+"-"+this.getUTCDate()+"T"+this.getUTCHours()+":"+this.getUTCMinutes()+":"+this.getUTCSeconds()+"Z"}),Date.now||(Date.now=function(){return(new Date).getTime()}),Date.prototype.toJSON||(Date.prototype.toJSON=function(){if("function"!=typeof this.toISOString)throw new TypeError;return this.toISOString()}),isNaN(Date.parse("T00:00"))&&(Date=function(e){var i,n=function(t,i,s,o,a,r,l){var d=arguments.length;return this instanceof e?(d=1===d&&String(t)===t?new e(n.parse(t)):d>=7?new e(t,i,s,o,a,r,l):d>=6?new e(t,i,s,o,a,r):d>=5?new e(t,i,s,o,a):d>=4?new e(t,i,s,o):d>=3?new e(t,i,s):d>=2?new e(t,i):d>=1?new e(t):new e,d.constructor=n,d):e.apply(this,arguments)},s=RegExp("^(?:((?:[+-]\\d\\d)?\\d\\d\\d\\d)(?:-(\\d\\d)(?:-(\\d\\d))?)?)?(?:T(\\d\\d):(\\d\\d)(?::(\\d\\d)(?:\\.(\\d\\d\\d))?)?)?(?:Z|([+-])(\\d\\d):(\\d\\d))?$");for(i in e)n[i]=e[i];return n.now=e.now,n.UTC=e.UTC,n.prototype=e.prototype,n.prototype.constructor=n,n.parse=function(i){var n=s.exec(i);if(n){n.shift();for(var o=n[0]===t,a=0;a<10;a++)7!==a&&(n[a]=+(n[a]||(a<3?1:0)),1===a&&n[a]--);return o?1e3*(60*(60*n[3]+n[4])+n[5])+n[6]:(o=6e4*(60*n[8]+n[9]),"-"===n[6]&&(o=-o),e.UTC.apply(this,n.slice(0,7))+o)}return e.parse.apply(this,arguments)},n}(Date)),!String.prototype.trim){var m=/^\s\s*/,f=/\s\s*$/;String.prototype.trim=function(){return String(this).replace(m,"").replace(f,"")}}}),"undefined"==typeof document||"classList"in document.createElement("a")||!function(t){var e="classList",i="prototype",n=(t.HTMLElement||t.Element)[i],s=Object,o=String[i].trim||function(){return this.replace(/^\s+|\s+$/g,"")},a=Array[i].indexOf||function(t){for(var e=0,i=this.length;e<i;e++)if(e in this&&this[e]===t)return e;return-1},r=function(t,e){this.name=t,this.code=DOMException[t],this.message=e},l=function(t,e){if(""===e)throw new r("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(e))throw new r("INVALID_CHARACTER_ERR","String contains an invalid character");return a.call(t,e)},d=function(t){for(var e=o.call(t.className),i=e?e.split(/\s+/):[],n=0,s=i.length;n<s;n++)this.push(i[n]);this._updateClassName=function(){t.className=this.toString()}},c=d[i]=[],h=function(){return new d(this)};if(r[i]=Error[i],c.item=function(t){return this[t]||null},c.contains=function(t){return t+="",l(this,t)!==-1},c.add=function(t){t+="",l(this,t)===-1&&(this.push(t),this._updateClassName())},c.remove=function(t){t+="";var e=l(this,t);e!==-1&&(this.splice(e,1),this._updateClassName())},c.toggle=function(t){t+="",l(this,t)===-1?this.add(t):this.remove(t)},c.toString=function(){return this.join(" ")},s.defineProperty){var u={get:h,enumerable:!0,configurable:!0};try{s.defineProperty(n,e,u)}catch(t){t.number===-2146823252&&(u.enumerable=!1,s.defineProperty(n,e,u))}}else s[i].__defineGetter__&&n.__defineGetter__(e,h)}(self),function(t){function e(t,e,i,n,s){this._listener=e,this._isOnce=i,this.context=n,this._signal=t,this._priority=s||0}function i(t,e){if("function"!=typeof t)throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",e))}function n(){this._bindings=[],this._prevParams=null;var t=this;this.dispatch=function(){n.prototype.dispatch.apply(t,arguments)}}e.prototype={active:!0,params:null,execute:function(t){var e,i;return this.active&&this._listener&&(i=this.params?this.params.concat(t):t,e=this._listener.apply(this.context,i),this._isOnce&&this.detach()),e},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},n.prototype={VERSION:"1.0.0",memorize:!1,_shouldPropagate:!0,active:!0,_registerListener:function(t,i,n,s){var o,a=this._indexOfListener(t,n);if(a!==-1){if(o=this._bindings[a],o.isOnce()!==i)throw new Error("You cannot add"+(i?"":"Once")+"() then add"+(i?"Once":"")+"() the same listener without removing the relationship first.")}else o=new e(this,t,i,n,s),this._addBinding(o);return this.memorize&&this._prevParams&&o.execute(this._prevParams),o},_addBinding:function(t){var e=this._bindings.length;do--e;while(this._bindings[e]&&t._priority<=this._bindings[e]._priority);this._bindings.splice(e+1,0,t)},_indexOfListener:function(t,e){for(var i,n=this._bindings.length;n--;)if(i=this._bindings[n],i._listener===t&&i.context===e)return n;return-1},has:function(t,e){return this._indexOfListener(t,e)!==-1},add:function(t,e,n){return i(t,"add"),this._registerListener(t,!1,e,n)},addOnce:function(t,e,n){return i(t,"addOnce"),this._registerListener(t,!0,e,n)},remove:function(t,e){i(t,"remove");var n=this._indexOfListener(t,e);return n!==-1&&(this._bindings[n]._destroy(),this._bindings.splice(n,1)),t},removeAll:function(){for(var t=this._bindings.length;t--;)this._bindings[t]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(){if(this.active){var t,e=Array.prototype.slice.call(arguments),i=this._bindings.length;if(this.memorize&&(this._prevParams=e),i){t=this._bindings.slice(),this._shouldPropagate=!0;do i--;while(t[i]&&this._shouldPropagate&&t[i].execute(e)!==!1)}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};var s=n;s.Signal=n,"function"==typeof define&&define.amd?define(function(){return s}):"undefined"!=typeof module&&module.exports?module.exports=s:t.signals=s}(this);var JSON;JSON||(JSON={}),function(){"use strict";function f(t){return t<10?"0"+t:t}function quote(t){return escapable.lastIndex=0,escapable.test(t)?'"'+t.replace(escapable,function(t){var e=meta[t];return"string"==typeof e?e:"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}function str(t,e){var i,n,s,o,a,r=gap,l=e[t];switch(l&&"object"==typeof l&&"function"==typeof l.toJSON&&(l=l.toJSON(t)),"function"==typeof rep&&(l=rep.call(e,t,l)),typeof l){case"string":return quote(l);case"number":return isFinite(l)?String(l):"null";case"boolean":case"null":return String(l);case"object":if(!l)return"null";if(gap+=indent,a=[],"[object Array]"===Object.prototype.toString.apply(l)){for(o=l.length,i=0;i<o;i+=1)a[i]=str(i,l)||"null";return s=0===a.length?"[]":gap?"[\n"+gap+a.join(",\n"+gap)+"\n"+r+"]":"["+a.join(",")+"]",gap=r,s}if(rep&&"object"==typeof rep)for(o=rep.length,i=0;i<o;i+=1)"string"==typeof rep[i]&&(n=rep[i],s=str(n,l),s&&a.push(quote(n)+(gap?": ":":")+s));else for(n in l)Object.prototype.hasOwnProperty.call(l,n)&&(s=str(n,l),s&&a.push(quote(n)+(gap?": ":":")+s));return s=0===a.length?"{}":gap?"{\n"+gap+a.join(",\n"+gap)+"\n"+r+"}":"{"+a.join(",")+"}",gap=r,s}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;"function"!=typeof JSON.stringify&&(JSON.stringify=function(t,e,i){var n;if(gap="",indent="","number"==typeof i)for(n=0;n<i;n+=1)indent+=" ";else"string"==typeof i&&(indent=i);if(rep=e,e&&"function"!=typeof e&&("object"!=typeof e||"number"!=typeof e.length))throw new Error("JSON.stringify");return str("",{"":t})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(t,e){var i,n,s=t[e];if(s&&"object"==typeof s)for(i in s)Object.prototype.hasOwnProperty.call(s,i)&&(n=walk(s,i),void 0!==n?s[i]=n:delete s[i]);return reviver.call(t,e,s)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(t){return"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),function(t){function e(t,e){return function(i){return l(t.call(this,i),e)}}function i(t,e){return function(i){return this.lang().ordinal(t.call(this,i),e)}}function n(){}function s(t){a(this,t)}function o(t){var e=t.years||t.year||t.y||0,i=t.months||t.month||t.M||0,n=t.weeks||t.week||t.w||0,s=t.days||t.day||t.d||0,o=t.hours||t.hour||t.h||0,a=t.minutes||t.minute||t.m||0,r=t.seconds||t.second||t.s||0,l=t.milliseconds||t.millisecond||t.ms||0;this._input=t,this._milliseconds=+l+1e3*r+6e4*a+36e5*o,this._days=+s+7*n,this._months=+i+12*e,this._data={},this._bubble()}function a(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t}function r(t){return 0>t?Math.ceil(t):Math.floor(t)}function l(t,e){for(var i=t+"";i.length<e;)i="0"+i;return i}function d(t,e,i,n){var s,o,a=e._milliseconds,r=e._days,l=e._months;a&&t._d.setTime(+t._d+a*i),(r||l)&&(s=t.minute(),o=t.hour()),r&&t.date(t.date()+r*i),l&&t.month(t.month()+l*i),a&&!n&&$.updateOffset(t),(r||l)&&(t.minute(s),t.hour(o))}function c(t){return"[object Array]"===Object.prototype.toString.call(t)}function h(t,e){var i,n=Math.min(t.length,e.length),s=Math.abs(t.length-e.length),o=0;for(i=0;n>i;i++)~~t[i]!==~~e[i]&&o++;return o+s}function u(t){return t?lt[t]||t.toLowerCase().replace(/(.)s$/,"$1"):t}function p(t,e){return e.abbr=t,H[t]||(H[t]=new n),H[t].set(e),H[t]}function m(t){delete H[t]}function f(t){if(!t)return $.fn._lang;if(!H[t]&&j)try{require("./lang/"+t)}catch(t){return $.fn._lang}return H[t]||$.fn._lang}function g(t){return t.match(/\[.*\]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function v(t){var e,i,n=t.match(G);for(e=0,i=n.length;i>e;e++)n[e]=ut[n[e]]?ut[n[e]]:g(n[e]);return function(s){var o="";for(e=0;i>e;e++)o+=n[e]instanceof Function?n[e].call(s,t):n[e];return o}}function b(t,e){return e=S(e,t.lang()),dt[e]||(dt[e]=v(e)),dt[e](t)}function S(t,e){function i(t){return e.longDateFormat(t)||t}for(var n=5;n--&&(W.lastIndex=0,W.test(t));)t=t.replace(W,i);return t}function y(t,e){switch(t){case"DDDD":return q;case"YYYY":return X;case"YYYYY":return J;case"S":case"SS":case"SSS":case"DDD":return Y;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return Q;case"a":case"A":return f(e._l)._meridiemParse;case"X":return et;case"Z":case"ZZ":return Z;case"T":return tt;case"MM":case"DD":case"YY":case"HH":case"hh":case"mm":case"ss":case"M":case"D":case"d":case"H":case"h":case"m":case"s":return K;default:return new RegExp(t.replace("\\",""))}}function E(t){var e=(Z.exec(t)||[])[0],i=(e+"").match(ot)||["-",0,0],n=+(60*i[1])+~~i[2];return"+"===i[0]?-n:n}function T(t,e,i){var n,s=i._a;switch(t){case"M":case"MM":null!=e&&(s[1]=~~e-1);break;case"MMM":case"MMMM":n=f(i._l).monthsParse(e),null!=n?s[1]=n:i._isValid=!1;break;case"D":case"DD":null!=e&&(s[2]=~~e);break;case"DDD":case"DDDD":null!=e&&(s[1]=0,s[2]=~~e);break;case"YY":s[0]=~~e+(~~e>68?1900:2e3);break;case"YYYY":case"YYYYY":s[0]=~~e;break;case"a":case"A":i._isPm=f(i._l).isPM(e);break;case"H":case"HH":case"h":case"hh":s[3]=~~e;break;case"m":case"mm":s[4]=~~e;break;case"s":case"ss":s[5]=~~e;break;case"S":case"SS":case"SSS":s[6]=~~(1e3*("0."+e));break;case"X":i._d=new Date(1e3*parseFloat(e));break;case"Z":case"ZZ":i._useUTC=!0,i._tzm=E(e)}null==e&&(i._isValid=!1)}function L(t){var e,i,n,s=[];if(!t._d){for(n=w(t),e=0;3>e&&null==t._a[e];++e)t._a[e]=s[e]=n[e];for(;7>e;e++)t._a[e]=s[e]=null==t._a[e]?2===e?1:0:t._a[e];s[3]+=~~((t._tzm||0)/60),s[4]+=~~((t._tzm||0)%60),i=new Date(0),t._useUTC?(i.setUTCFullYear(s[0],s[1],s[2]),i.setUTCHours(s[3],s[4],s[5],s[6])):(i.setFullYear(s[0],s[1],s[2]),i.setHours(s[3],s[4],s[5],s[6])),t._d=i}}function k(t){var e=t._i;t._d||(t._a=[e.years||e.year||e.y,e.months||e.month||e.M,e.days||e.day||e.d,e.hours||e.hour||e.h,e.minutes||e.minute||e.m,e.seconds||e.second||e.s,e.milliseconds||e.millisecond||e.ms],L(t))}function w(t){var e=new Date;return t._useUTC?[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()]:[e.getFullYear(),e.getMonth(),e.getDate()]}function C(t){var e,i,n,s=f(t._l),o=""+t._i;for(n=S(t._f,s).match(G),t._a=[],e=0;e<n.length;e++)i=(y(n[e],t).exec(o)||[])[0],i&&(o=o.slice(o.indexOf(i)+i.length)),ut[n[e]]&&T(n[e],i,t);o&&(t._il=o),t._isPm&&t._a[3]<12&&(t._a[3]+=12),t._isPm===!1&&12===t._a[3]&&(t._a[3]=0),L(t)}function _(t){var e,i,n,o,r,l=99;for(o=0;o<t._f.length;o++)e=a({},t),e._f=t._f[o],C(e),i=new s(e),r=h(e._a,i.toArray()),i._il&&(r+=i._il.length),l>r&&(l=r,n=i);a(t,n)}function D(t){var e,i=t._i,n=it.exec(i);if(n){for(t._f="YYYY-MM-DD"+(n[2]||" "),e=0;4>e;e++)if(st[e][1].exec(i)){t._f+=st[e][0];break}Z.exec(i)&&(t._f+=" Z"),C(t)}else t._d=new Date(i)}function A(e){var i=e._i,n=V.exec(i);i===t?e._d=new Date:n?e._d=new Date(+n[1]):"string"==typeof i?D(e):c(i)?(e._a=i.slice(0),L(e)):i instanceof Date?e._d=new Date(+i):"object"==typeof i?k(e):e._d=new Date(i)}function I(t,e,i,n,s){return s.relativeTime(e||1,!!i,t,n)}function x(t,e,i){var n=B(Math.abs(t)/1e3),s=B(n/60),o=B(s/60),a=B(o/24),r=B(a/365),l=45>n&&["s",n]||1===s&&["m"]||45>s&&["mm",s]||1===o&&["h"]||22>o&&["hh",o]||1===a&&["d"]||25>=a&&["dd",a]||45>=a&&["M"]||345>a&&["MM",B(a/30)]||1===r&&["y"]||["yy",r];return l[2]=e,l[3]=t>0,l[4]=i,I.apply({},l)}function R(t,e,i){var n,s=i-e,o=i-t.day();return o>s&&(o-=7),s-7>o&&(o+=7),n=$(t).add("d",o),{week:Math.ceil(n.dayOfYear()/7),year:n.year()}}function M(t){var e=t._i,i=t._f;return null===e||""===e?null:("string"==typeof e&&(t._i=e=f().preparse(e)),$.isMoment(e)?(t=a({},e),t._d=new Date(+e._d)):i?c(i)?_(t):C(t):A(t),new s(t))}function O(t,e){$.fn[t]=$.fn[t+"s"]=function(t){var i=this._isUTC?"UTC":"";return null!=t?(this._d["set"+i+e](t),$.updateOffset(this),this):this._d["get"+i+e]()}}function P(t){$.duration.fn[t]=function(){return this._data[t]}}function N(t,e){$.duration.fn["as"+t]=function(){return+this/e}}for(var $,U,F="2.2.1",B=Math.round,H={},j="undefined"!=typeof module&&module.exports,V=/^\/?Date\((\-?\d+)/i,z=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)\:(\d+)\.?(\d{3})?/,G=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/g,W=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,K=/\d\d?/,Y=/\d{1,3}/,q=/\d{3}/,X=/\d{1,4}/,J=/[+\-]?\d{1,6}/,Q=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Z=/Z|[\+\-]\d\d:?\d\d/i,tt=/T/i,et=/[\+\-]?\d+(\.\d{1,3})?/,it=/^\s*\d{4}-\d\d-\d\d((T| )(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,nt="YYYY-MM-DDTHH:mm:ssZ",st=[["HH:mm:ss.S",/(T| )\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],ot=/([\+\-]|\d\d)/gi,at="Date|Hours|Minutes|Seconds|Milliseconds".split("|"),rt={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},lt={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",w:"week",W:"isoweek",M:"month",y:"year"},dt={},ct="DDD w W M D d".split(" "),ht="M D H h m s w W".split(" "),ut={M:function(){return this.month()+1},MMM:function(t){return this.lang().monthsShort(this,t)},MMMM:function(t){return this.lang().months(this,t)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(t){return this.lang().weekdaysMin(this,t)},ddd:function(t){return this.lang().weekdaysShort(this,t)},dddd:function(t){return this.lang().weekdays(this,t)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return l(this.year()%100,2)},YYYY:function(){return l(this.year(),4)},YYYYY:function(){return l(this.year(),5)},gg:function(){return l(this.weekYear()%100,2)},gggg:function(){return this.weekYear()},ggggg:function(){return l(this.weekYear(),5)},GG:function(){return l(this.isoWeekYear()%100,2)},GGGG:function(){return this.isoWeekYear()},GGGGG:function(){return l(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return~~(this.milliseconds()/100)},SS:function(){return l(~~(this.milliseconds()/10),2)},SSS:function(){return l(this.milliseconds(),3)},Z:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+l(~~(t/60),2)+":"+l(~~t%60,2)},ZZ:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+l(~~(10*t/6),4)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()}};ct.length;)U=ct.pop(),ut[U+"o"]=i(ut[U],U);for(;ht.length;)U=ht.pop(),ut[U+U]=e(ut[U],2);for(ut.DDDD=e(ut.DDD,3),a(n.prototype,{set:function(t){var e,i;for(i in t)e=t[i],"function"==typeof e?this[i]=e:this["_"+i]=e},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(t){return this._months[t.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(t){return this._monthsShort[t.month()]},monthsParse:function(t){var e,i,n;for(this._monthsParse||(this._monthsParse=[]),e=0;12>e;e++)if(this._monthsParse[e]||(i=$.utc([2e3,e]),n="^"+this.months(i,"")+"|^"+this.monthsShort(i,""),this._monthsParse[e]=new RegExp(n.replace(".",""),"i")),this._monthsParse[e].test(t))return e},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(t){return this._weekdays[t.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(t){return this._weekdaysShort[t.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(t){return this._weekdaysMin[t.day()]},weekdaysParse:function(t){var e,i,n;for(this._weekdaysParse||(this._weekdaysParse=[]),e=0;7>e;e++)if(this._weekdaysParse[e]||(i=$([2e3,1]).day(e),n="^"+this.weekdays(i,"")+"|^"+this.weekdaysShort(i,"")+"|^"+this.weekdaysMin(i,""),this._weekdaysParse[e]=new RegExp(n.replace(".",""),"i")),this._weekdaysParse[e].test(t))return e},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},longDateFormat:function(t){var e=this._longDateFormat[t];return!e&&this._longDateFormat[t.toUpperCase()]&&(e=this._longDateFormat[t.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(t){return t.slice(1)}),this._longDateFormat[t]=e),e},isPM:function(t){return"p"===(t+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(t,e,i){return t>11?i?"pm":"PM":i?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(t,e){var i=this._calendar[t];return"function"==typeof i?i.apply(e):i},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(t,e,i,n){var s=this._relativeTime[i];return"function"==typeof s?s(t,e,i,n):s.replace(/%d/i,t)},pastFuture:function(t,e){var i=this._relativeTime[t>0?"future":"past"];return"function"==typeof i?i(e):i.replace(/%s/i,e)},ordinal:function(t){return this._ordinal.replace("%d",t)},_ordinal:"%d",preparse:function(t){return t},postformat:function(t){return t},week:function(t){return R(t,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6}}),$=function(t,e,i){return M({_i:t,_f:e,_l:i,_isUTC:!1})},$.utc=function(t,e,i){return M({_useUTC:!0,_isUTC:!0,_l:i,_i:t,_f:e}).utc()},$.unix=function(t){return $(1e3*t)},$.duration=function(t,e){var i,n,s=$.isDuration(t),a="number"==typeof t,r=s?t._input:a?{}:t,l=z.exec(t);return a?e?r[e]=t:r.milliseconds=t:l&&(i="-"===l[1]?-1:1,r={y:0,d:~~l[2]*i,h:~~l[3]*i,m:~~l[4]*i,s:~~l[5]*i,ms:~~l[6]*i}),n=new o(r),s&&t.hasOwnProperty("_lang")&&(n._lang=t._lang),n},$.version=F,$.defaultFormat=nt,$.updateOffset=function(){},$.lang=function(t,e){return t?(t=t.toLowerCase(),t=t.replace("_","-"),e?p(t,e):null===e?(m(t),t="en"):H[t]||f(t),void($.duration.fn._lang=$.fn._lang=f(t))):$.fn._lang._abbr},$.langData=function(t){return t&&t._lang&&t._lang._abbr&&(t=t._lang._abbr),f(t)},$.isMoment=function(t){return t instanceof s},$.isDuration=function(t){return t instanceof o},a($.fn=s.prototype,{clone:function(){return $(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){return b($(this).utc(),"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){var t=this;return[t.year(),t.month(),t.date(),t.hours(),t.minutes(),t.seconds(),t.milliseconds()]},isValid:function(){return null==this._isValid&&(this._isValid=this._a?!h(this._a,(this._isUTC?$.utc(this._a):$(this._a)).toArray()):!isNaN(this._d.getTime())),!!this._isValid},invalidAt:function(){var t,e=this._a,i=(this._isUTC?$.utc(this._a):$(this._a)).toArray();for(t=6;t>=0&&e[t]===i[t];--t);return t},utc:function(){return this.zone(0)},local:function(){return this.zone(0),this._isUTC=!1,this},format:function(t){var e=b(this,t||$.defaultFormat);return this.lang().postformat(e)},add:function(t,e){var i;return i="string"==typeof t?$.duration(+e,t):$.duration(t,e),d(this,i,1),this},subtract:function(t,e){var i;return i="string"==typeof t?$.duration(+e,t):$.duration(t,e),d(this,i,-1),this},diff:function(t,e,i){var n,s,o=this._isUTC?$(t).zone(this._offset||0):$(t).local(),a=6e4*(this.zone()-o.zone());return e=u(e),"year"===e||"month"===e?(n=432e5*(this.daysInMonth()+o.daysInMonth()),s=12*(this.year()-o.year())+(this.month()-o.month()),s+=(this-$(this).startOf("month")-(o-$(o).startOf("month")))/n,s-=6e4*(this.zone()-$(this).startOf("month").zone()-(o.zone()-$(o).startOf("month").zone()))/n,"year"===e&&(s/=12)):(n=this-o,s="second"===e?n/1e3:"minute"===e?n/6e4:"hour"===e?n/36e5:"day"===e?(n-a)/864e5:"week"===e?(n-a)/6048e5:n),i?s:r(s)},from:function(t,e){return $.duration(this.diff(t)).lang(this.lang()._abbr).humanize(!e)},fromNow:function(t){return this.from($(),t)},calendar:function(){var t=this.diff($().zone(this.zone()).startOf("day"),"days",!0),e=-6>t?"sameElse":-1>t?"lastWeek":0>t?"lastDay":1>t?"sameDay":2>t?"nextDay":7>t?"nextWeek":"sameElse";return this.format(this.lang().calendar(e,this))},isLeapYear:function(){var t=this.year();return 0===t%4&&0!==t%100||0===t%400},isDST:function(){return this.zone()<this.clone().month(0).zone()||this.zone()<this.clone().month(5).zone()},day:function(t){var e=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=t?"string"==typeof t&&(t=this.lang().weekdaysParse(t),"number"!=typeof t)?this:this.add({d:t-e}):e},month:function(t){var e,i=this._isUTC?"UTC":"";return null!=t?"string"==typeof t&&(t=this.lang().monthsParse(t),"number"!=typeof t)?this:(e=this.date(),this.date(1),this._d["set"+i+"Month"](t),this.date(Math.min(e,this.daysInMonth())),$.updateOffset(this),this):this._d["get"+i+"Month"]()},startOf:function(t){switch(t=u(t)){case"year":this.month(0);case"month":this.date(1);case"week":case"isoweek":case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===t?this.weekday(0):"isoweek"===t&&this.isoWeekday(1),this},endOf:function(t){return t=u(t),this.startOf(t).add("isoweek"===t?"week":t,1).subtract("ms",1)},isAfter:function(t,e){return e="undefined"!=typeof e?e:"millisecond",+this.clone().startOf(e)>+$(t).startOf(e)},isBefore:function(t,e){return e="undefined"!=typeof e?e:"millisecond",+this.clone().startOf(e)<+$(t).startOf(e)},isSame:function(t,e){return e="undefined"!=typeof e?e:"millisecond",+this.clone().startOf(e)===+$(t).startOf(e)},min:function(t){return t=$.apply(null,arguments),this>t?this:t},max:function(t){return t=$.apply(null,arguments),t>this?this:t},zone:function(t){var e=this._offset||0;return null==t?this._isUTC?e:this._d.getTimezoneOffset():("string"==typeof t&&(t=E(t)),Math.abs(t)<16&&(t*=60),this._offset=t,this._isUTC=!0,e!==t&&d(this,$.duration(e-t,"m"),1,!0),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},hasAlignedHourOffset:function(t){return t=t?$(t).zone():0,0===(this.zone()-t)%60},daysInMonth:function(){return $.utc([this.year(),this.month()+1,0]).date()},dayOfYear:function(t){var e=B(($(this).startOf("day")-$(this).startOf("year"))/864e5)+1;return null==t?e:this.add("d",t-e)},weekYear:function(t){var e=R(this,this.lang()._week.dow,this.lang()._week.doy).year;return null==t?e:this.add("y",t-e)},isoWeekYear:function(t){var e=R(this,1,4).year;return null==t?e:this.add("y",t-e)},week:function(t){var e=this.lang().week(this);return null==t?e:this.add("d",7*(t-e))},isoWeek:function(t){var e=R(this,1,4).week;return null==t?e:this.add("d",7*(t-e))},weekday:function(t){var e=(this._d.getDay()+7-this.lang()._week.dow)%7;return null==t?e:this.add("d",t-e)},isoWeekday:function(t){return null==t?this.day()||7:this.day(this.day()%7?t:t-7)},get:function(t){return t=u(t),this[t.toLowerCase()]()},set:function(t,e){t=u(t),this[t.toLowerCase()](e)},lang:function(e){return e===t?this._lang:(this._lang=f(e),this)}}),U=0;U<at.length;U++)O(at[U].toLowerCase().replace(/s$/,""),at[U]);O("year","FullYear"),$.fn.days=$.fn.day,$.fn.months=$.fn.month,$.fn.weeks=$.fn.week,$.fn.isoWeeks=$.fn.isoWeek,$.fn.toJSON=$.fn.toISOString,a($.duration.fn=o.prototype,{_bubble:function(){var t,e,i,n,s=this._milliseconds,o=this._days,a=this._months,l=this._data;l.milliseconds=s%1e3,t=r(s/1e3),l.seconds=t%60,e=r(t/60),l.minutes=e%60,i=r(e/60),l.hours=i%24,o+=r(i/24),l.days=o%30,a+=r(o/30),l.months=a%12,n=r(a/12),l.years=n},weeks:function(){return r(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+2592e6*(this._months%12)+31536e6*~~(this._months/12)},humanize:function(t){var e=+this,i=x(e,!t,this.lang());return t&&(i=this.lang().pastFuture(e,i)),this.lang().postformat(i)},add:function(t,e){var i=$.duration(t,e);return this._milliseconds+=i._milliseconds,this._days+=i._days,this._months+=i._months,this._bubble(),this},subtract:function(t,e){var i=$.duration(t,e);return this._milliseconds-=i._milliseconds,this._days-=i._days,this._months-=i._months,this._bubble(),this},get:function(t){return t=u(t),this[t.toLowerCase()+"s"]()},as:function(t){return t=u(t),this["as"+t.charAt(0).toUpperCase()+t.slice(1)+"s"]()},lang:$.fn.lang});for(U in rt)rt.hasOwnProperty(U)&&(N(U,rt[U]),P(U.toLowerCase()));N("Weeks",6048e5),$.duration.fn.asMonths=function(){return(+this-31536e6*this.years())/2592e6+12*this.years()},$.lang("en",{ordinal:function(t){var e=t%10,i=1===~~(t%100/10)?"th":1===e?"st":2===e?"nd":3===e?"rd":"th";return t+i}}),j&&(module.exports=$),"undefined"==typeof ender&&(this.moment=$),"function"==typeof define&&define.amd&&define("moment",[],function(){return $})}.call(this),function(t,e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Spinner=e()}(this,function(){"use strict";function t(t,e){var i,n=document.createElement(t||"div");for(i in e)n[i]=e[i];return n}function e(t){for(var e=1,i=arguments.length;e<i;e++)t.appendChild(arguments[e]);return t}function i(t,e,i,n){var s=["opacity",e,~~(100*t),i,n].join("-"),o=.01+i/n*100,a=Math.max(1-(1-t)/e*(100-o),t),r=d.substring(0,d.indexOf("Animation")).toLowerCase(),l=r&&"-"+r+"-"||"";return h[s]||(u.insertRule("@"+l+"keyframes "+s+"{0%{opacity:"+a+"}"+o+"%{opacity:"+t+"}"+(o+.01)+"%{opacity:1}"+(o+e)%100+"%{opacity:"+t+"}100%{opacity:"+a+"}}",u.cssRules.length),h[s]=1),s}function n(t,e){var i,n,s=t.style;if(void 0!==s[e])return e;
for(e=e.charAt(0).toUpperCase()+e.slice(1),n=0;n<c.length;n++)if(i=c[n]+e,void 0!==s[i])return i}function s(t,e){for(var i in e)t.style[n(t,i)||i]=e[i];return t}function o(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)void 0===t[n]&&(t[n]=i[n])}return t}function a(t){for(var e={x:t.offsetLeft,y:t.offsetTop};t=t.offsetParent;)e.x+=t.offsetLeft,e.y+=t.offsetTop;return e}function r(t){return"undefined"==typeof this?new r(t):void(this.opts=o(t||{},r.defaults,p))}function l(){function i(e,i){return t("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',i)}u.addRule(".spin-vml","behavior:url(#default#VML)"),r.prototype.lines=function(t,n){function o(){return s(i("group",{coordsize:d+" "+d,coordorigin:-l+" "+-l}),{width:d,height:d})}function a(t,a,r){e(h,e(s(o(),{rotation:360/n.lines*t+"deg",left:~~a}),e(s(i("roundrect",{arcsize:n.corners}),{width:l,height:n.width,left:n.radius,top:-n.width>>1,filter:r}),i("fill",{color:n.color,opacity:n.opacity}),i("stroke",{opacity:0}))))}var r,l=n.length+n.width,d=2*l,c=2*-(n.width+n.length)+"px",h=s(o(),{position:"absolute",top:c,left:c});if(n.shadow)for(r=1;r<=n.lines;r++)a(r,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(r=1;r<=n.lines;r++)a(r);return e(t,h)},r.prototype.opacity=function(t,e,i,n){var s=t.firstChild;n=n.shadow&&n.lines||0,s&&e+n<s.childNodes.length&&(s=s.childNodes[e+n],s=s&&s.firstChild,s=s&&s.firstChild,s&&(s.opacity=i))}}var d,c=["webkit","Moz","ms","O"],h={},u=function(){var i=t("style",{type:"text/css"});return e(document.getElementsByTagName("head")[0],i),i.sheet||i.styleSheet}(),p={lines:12,length:7,width:5,radius:10,rotate:0,corners:1,color:"#000",direction:1,speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"spinner",top:"auto",left:"auto",position:"relative"};r.defaults={},o(r.prototype,{spin:function(e){this.stop();var i,n,o=this,r=o.opts,l=o.el=s(t(0,{className:r.className}),{position:r.position,width:0,zIndex:r.zIndex}),c=r.radius+r.length+r.width;if(e&&(e.insertBefore(l,e.firstChild||null),n=a(e),i=a(l),s(l,{left:("auto"==r.left?n.x-i.x+(e.offsetWidth>>1):parseInt(r.left,10)+c)+"px",top:("auto"==r.top?n.y-i.y+(e.offsetHeight>>1):parseInt(r.top,10)+c)+"px"})),l.setAttribute("role","progressbar"),o.lines(l,o.opts),!d){var h,u=0,p=(r.lines-1)*(1-r.direction)/2,m=r.fps,f=m/r.speed,g=(1-r.opacity)/(f*r.trail/100),v=f/r.lines;!function t(){u++;for(var e=0;e<r.lines;e++)h=Math.max(1-(u+(r.lines-e)*v)%f*g,r.opacity),o.opacity(l,e*r.direction+p,h,r);o.timeout=o.el&&setTimeout(t,~~(1e3/m))}()}return o},stop:function(){var t=this.el;return t&&(clearTimeout(this.timeout),t.parentNode&&t.parentNode.removeChild(t),this.el=void 0),this},lines:function(n,o){function a(e,i){return s(t(),{position:"absolute",width:o.length+o.width+"px",height:o.width+"px",background:e,boxShadow:i,transformOrigin:"left",transform:"rotate("+~~(360/o.lines*l+o.rotate)+"deg) translate("+o.radius+"px,0)",borderRadius:(o.corners*o.width>>1)+"px"})}for(var r,l=0,c=(o.lines-1)*(1-o.direction)/2;l<o.lines;l++)r=s(t(),{position:"absolute",top:1+~(o.width/2)+"px",transform:o.hwaccel?"translate3d(0,0,0)":"",opacity:o.opacity,animation:d&&i(o.opacity,o.trail,c+l*o.direction,o.lines)+" "+1/o.speed+"s linear infinite"}),o.shadow&&e(r,s(a("#000","0 0 4px #000"),{top:"2px"})),e(n,e(r,a(o.color,"0 0 1px rgba(0,0,0,.1)")));return n},opacity:function(t,e,i){e<t.childNodes.length&&(t.childNodes[e].style.opacity=i)}});var m=s(t("group"),{behavior:"url(#default#VML)"});return!n(m,"transform")&&m.adj?l():d=n(m,"animation"),r}),function(t,e){"object"==typeof exports?module.exports=e(require("spin.js")):"function"==typeof define&&define.amd?define(["spin"],e):t.Ladda=e(t.Spinner)}(this,function(t){"use strict";function e(t){if("undefined"==typeof t)return void console.warn("Ladda button target must be defined.");t.querySelector(".ladda-label")||(t.innerHTML='<span class="ladda-label">'+t.innerHTML+"</span>");var e,i=t.querySelector(".ladda-spinner");i||(i=document.createElement("span"),i.className="ladda-spinner"),t.appendChild(i);var n,s={start:function(){return e||(e=a(t)),t.setAttribute("disabled",""),t.setAttribute("data-loading",""),clearTimeout(n),e.spin(i),this.setProgress(0),this},startAfter:function(t){return clearTimeout(n),n=setTimeout(function(){s.start()},t),this},stop:function(){return t.removeAttribute("disabled"),t.removeAttribute("data-loading"),clearTimeout(n),e&&(n=setTimeout(function(){e.stop()},1e3)),this},toggle:function(){return this.isLoading()?this.stop():this.start(),this},setProgress:function(e){e=Math.max(Math.min(e,1),0);var i=t.querySelector(".ladda-progress");0===e&&i&&i.parentNode?i.parentNode.removeChild(i):(i||(i=document.createElement("div"),i.className="ladda-progress",t.appendChild(i)),i.style.width=(e||0)*t.offsetWidth+"px")},enable:function(){return this.stop(),this},disable:function(){return this.stop(),t.setAttribute("disabled",""),this},isLoading:function(){return t.hasAttribute("data-loading")},remove:function(){clearTimeout(n),t.removeAttribute("disabled",""),t.removeAttribute("data-loading",""),e&&(e.stop(),e=null);for(var i=0,o=l.length;i<o;i++)if(s===l[i]){l.splice(i,1);break}}};return l.push(s),s}function i(t,e){for(;t.parentNode&&t.tagName!==e;)t=t.parentNode;return e===t.tagName?t:void 0}function n(t){for(var e=["input","textarea","select"],i=[],n=0;n<e.length;n++)for(var s=t.getElementsByTagName(e[n]),o=0;o<s.length;o++)s[o].hasAttribute("required")&&i.push(s[o]);return i}function s(t,s){s=s||{};var o=[];"string"==typeof t?o=r(document.querySelectorAll(t)):"object"==typeof t&&"string"==typeof t.nodeName&&(o=[t]);for(var a=0,l=o.length;a<l;a++)!function(){var t=o[a];if("function"==typeof t.addEventListener){var r=e(t),l=-1;t.addEventListener("click",function(){var e=!0,o=i(t,"FORM");if("undefined"!=typeof o)for(var a=n(o),d=0;d<a.length;d++)""===a[d].value.replace(/^\s+|\s+$/g,"")&&(e=!1),"checkbox"!==a[d].type&&"radio"!==a[d].type||a[d].checked||(e=!1);e&&(r.startAfter(1),"number"==typeof s.timeout&&(clearTimeout(l),l=setTimeout(r.stop,s.timeout)),"function"==typeof s.callback&&s.callback.apply(null,[r]))},!1)}}()}function o(){for(var t=0,e=l.length;t<e;t++)l[t].stop()}function a(e){var i,n=e.offsetHeight;0===n&&(n=parseFloat(window.getComputedStyle(e).height)),n>32&&(n*=.8),e.hasAttribute("data-spinner-size")&&(n=parseInt(e.getAttribute("data-spinner-size"),10)),e.hasAttribute("data-spinner-color")&&(i=e.getAttribute("data-spinner-color"));var s=12,o=.2*n,a=.6*o,r=o<7?2:3;return new t({color:i||"#fff",lines:s,radius:o,length:a,width:r,zIndex:"auto",top:"auto",left:"auto",className:""})}function r(t){for(var e=[],i=0;i<t.length;i++)e.push(t[i]);return e}var l=[];return{bind:s,create:e,stopAll:o}}),function(t,e){function i(t,e,i){return t.addEventListener?void t.addEventListener(e,i,!1):void t.attachEvent("on"+e,i)}function n(t){if("keypress"==t.type){var e=String.fromCharCode(t.which);return t.shiftKey||(e=e.toLowerCase()),e}return k[t.which]?k[t.which]:w[t.which]?w[t.which]:String.fromCharCode(t.which).toLowerCase()}function s(t,e){return t.sort().join(",")===e.sort().join(",")}function o(t){t=t||{};var e,i=!1;for(e in I)t[e]?i=!0:I[e]=0;i||(M=!1)}function a(t,e,i,n,o,a){var r,l,d=[],c=i.type;if(!D[t])return[];for("keyup"==c&&p(t)&&(e=[t]),r=0;r<D[t].length;++r)if(l=D[t][r],(n||!l.seq||I[l.seq]==l.level)&&c==l.action&&("keypress"==c&&!i.metaKey&&!i.ctrlKey||s(e,l.modifiers))){var h=!n&&l.combo==o,u=n&&l.seq==n&&l.level==a;(h||u)&&D[t].splice(r,1),d.push(l)}return d}function r(t){var e=[];return t.shiftKey&&e.push("shift"),t.altKey&&e.push("alt"),t.ctrlKey&&e.push("ctrl"),t.metaKey&&e.push("meta"),e}function l(t){return t.preventDefault?void t.preventDefault():void(t.returnValue=!1)}function d(t){return t.stopPropagation?void t.stopPropagation():void(t.cancelBubble=!0)}function c(t,e,i,n){P.stopCallback(e,e.target||e.srcElement,i,n)||t(e,i)===!1&&(l(e),d(e))}function h(t,e,i){var n,s=a(t,e,i),r={},l=0,d=!1;for(n=0;n<s.length;++n)s[n].seq&&(l=Math.max(l,s[n].level));for(n=0;n<s.length;++n)if(s[n].seq){if(s[n].level!=l)continue;d=!0,r[s[n].seq]=1,c(s[n].callback,i,s[n].combo,s[n].seq)}else d||c(s[n].callback,i,s[n].combo);var h="keypress"==i.type&&R;i.type!=M||p(t)||h||o(r),R=d&&"keydown"==i.type}function u(t){"number"!=typeof t.which&&(t.which=t.keyCode);var e=n(t);if(e)return"keyup"==t.type&&x===e?void(x=!1):void P.handleKey(e,r(t),t)}function p(t){return"shift"==t||"ctrl"==t||"alt"==t||"meta"==t}function m(){clearTimeout(L),L=setTimeout(o,1e3)}function f(){if(!T){T={};for(var t in k)t>95&&t<112||k.hasOwnProperty(t)&&(T[k[t]]=t)}return T}function g(t,e,i){return i||(i=f()[t]?"keydown":"keypress"),"keypress"==i&&e.length&&(i="keydown"),i}function v(t,e,i,s){function a(e){return function(){M=e,++I[t],m()}}function r(e){c(i,e,t),"keyup"!==s&&(x=n(e)),setTimeout(o,10)}I[t]=0;for(var l=0;l<e.length;++l){var d=l+1===e.length,h=d?r:a(s||S(e[l+1]).action);y(e[l],h,s,t,l)}}function b(t){return"+"===t?["+"]:t.split("+")}function S(t,e){var i,n,s,o=[];for(i=b(t),s=0;s<i.length;++s)n=i[s],_[n]&&(n=_[n]),e&&"keypress"!=e&&C[n]&&(n=C[n],o.push("shift")),p(n)&&o.push(n);return e=g(n,o,e),{key:n,modifiers:o,action:e}}function y(t,e,i,n,s){A[t+":"+i]=e,t=t.replace(/\s+/g," ");var o,r=t.split(" ");return r.length>1?void v(t,r,e,i):(o=S(t,i),D[o.key]=D[o.key]||[],a(o.key,o.modifiers,{type:o.action},n,t,s),void D[o.key][n?"unshift":"push"]({callback:e,modifiers:o.modifiers,action:o.action,seq:n,level:s,combo:t}))}function E(t,e,i){for(var n=0;n<t.length;++n)y(t[n],e,i)}for(var T,L,k={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",224:"meta"},w={106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},C={"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},_={option:"alt",command:"meta","return":"enter",escape:"esc",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},D={},A={},I={},x=!1,R=!1,M=!1,O=1;O<20;++O)k[111+O]="f"+O;for(O=0;O<=9;++O)k[O+96]=O;i(e,"keypress",u),i(e,"keydown",u),i(e,"keyup",u);var P={bind:function(t,e,i){return t=t instanceof Array?t:[t],E(t,e,i),this},unbind:function(t,e){return P.bind(t,function(){},e)},trigger:function(t,e){return A[t+":"+e]&&A[t+":"+e]({},t),this},reset:function(){return D={},A={},this},stopCallback:function(t,e){return!((" "+e.className+" ").indexOf(" mousetrap ")>-1)&&("INPUT"==e.tagName||"SELECT"==e.tagName||"TEXTAREA"==e.tagName||e.isContentEditable)},handleKey:h};t.Mousetrap=P,"function"==typeof define&&define.amd&&define(P)}(window,document),function(t,e,i,n){"use strict";function s(t,e,i){return setTimeout(c(t,i),e)}function o(t,e,i){return!!Array.isArray(t)&&(a(t,i[e],i),!0)}function a(t,e,i){var s;if(t)if(t.forEach)t.forEach(e,i);else if(t.length!==n)for(s=0;s<t.length;)e.call(i,t[s],s,t),s++;else for(s in t)t.hasOwnProperty(s)&&e.call(i,t[s],s,t)}function r(t,e,i){for(var s=Object.keys(e),o=0;o<s.length;)(!i||i&&t[s[o]]===n)&&(t[s[o]]=e[s[o]]),o++;return t}function l(t,e){return r(t,e,!0)}function d(t,e,i){var n,s=e.prototype;n=t.prototype=Object.create(s),n.constructor=t,n._super=s,i&&r(n,i)}function c(t,e){return function(){return t.apply(e,arguments)}}function h(t,e){return typeof t==ct?t.apply(e?e[0]||n:n,e):t}function u(t,e){return t===n?e:t}function p(t,e,i){a(v(e),function(e){t.addEventListener(e,i,!1)})}function m(t,e,i){a(v(e),function(e){t.removeEventListener(e,i,!1)})}function f(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function g(t,e){return t.indexOf(e)>-1}function v(t){return t.trim().split(/\s+/g)}function b(t,e,i){if(t.indexOf&&!i)return t.indexOf(e);for(var n=0;n<t.length;){if(i&&t[n][i]==e||!i&&t[n]===e)return n;n++}return-1}function S(t){return Array.prototype.slice.call(t,0)}function y(t,e,i){for(var n=[],s=[],o=0;o<t.length;){var a=e?t[o][e]:t[o];b(s,a)<0&&n.push(t[o]),s[o]=a,o++}return i&&(n=e?n.sort(function(t,i){return t[e]>i[e]}):n.sort()),n}function E(t,e){for(var i,s,o=e[0].toUpperCase()+e.slice(1),a=0;a<lt.length;){if(i=lt[a],s=i?i+o:e,s in t)return s;a++}return n}function T(){return mt++}function L(t){var e=t.ownerDocument;return e.defaultView||e.parentWindow}function k(t,e){var i=this;this.manager=t,this.callback=e,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(e){h(t.options.enable,[t])&&i.handler(e)},this.init()}function w(t){var e,i=t.options.inputClass;return new(e=i?i:vt?F:bt?j:gt?z:U)(t,C)}function C(t,e,i){var n=i.pointers.length,s=i.changedPointers.length,o=e&kt&&n-s===0,a=e&(Ct|_t)&&n-s===0;i.isFirst=!!o,i.isFinal=!!a,o&&(t.session={}),i.eventType=e,_(t,i),t.emit("hammer.input",i),t.recognize(i),t.session.prevInput=i}function _(t,e){var i=t.session,n=e.pointers,s=n.length;i.firstInput||(i.firstInput=I(e)),s>1&&!i.firstMultiple?i.firstMultiple=I(e):1===s&&(i.firstMultiple=!1);var o=i.firstInput,a=i.firstMultiple,r=a?a.center:o.center,l=e.center=x(n);e.timeStamp=pt(),e.deltaTime=e.timeStamp-o.timeStamp,e.angle=P(r,l),e.distance=O(r,l),D(i,e),e.offsetDirection=M(e.deltaX,e.deltaY),e.scale=a?$(a.pointers,n):1,e.rotation=a?N(a.pointers,n):0,A(i,e);var d=t.element;f(e.srcEvent.target,d)&&(d=e.srcEvent.target),e.target=d}function D(t,e){var i=e.center,n=t.offsetDelta||{},s=t.prevDelta||{},o=t.prevInput||{};e.eventType!==kt&&o.eventType!==Ct||(s=t.prevDelta={x:o.deltaX||0,y:o.deltaY||0},n=t.offsetDelta={x:i.x,y:i.y}),e.deltaX=s.x+(i.x-n.x),e.deltaY=s.y+(i.y-n.y)}function A(t,e){var i,s,o,a,r=t.lastInterval||e,l=e.timeStamp-r.timeStamp;if(e.eventType!=_t&&(l>Lt||r.velocity===n)){var d=r.deltaX-e.deltaX,c=r.deltaY-e.deltaY,h=R(l,d,c);s=h.x,o=h.y,i=ut(h.x)>ut(h.y)?h.x:h.y,a=M(d,c),t.lastInterval=e}else i=r.velocity,s=r.velocityX,o=r.velocityY,a=r.direction;e.velocity=i,e.velocityX=s,e.velocityY=o,e.direction=a}function I(t){for(var e=[],i=0;i<t.pointers.length;)e[i]={clientX:ht(t.pointers[i].clientX),clientY:ht(t.pointers[i].clientY)},i++;return{timeStamp:pt(),pointers:e,center:x(e),deltaX:t.deltaX,deltaY:t.deltaY}}function x(t){var e=t.length;if(1===e)return{x:ht(t[0].clientX),y:ht(t[0].clientY)};for(var i=0,n=0,s=0;s<e;)i+=t[s].clientX,n+=t[s].clientY,s++;return{x:ht(i/e),y:ht(n/e)}}function R(t,e,i){return{x:e/t||0,y:i/t||0}}function M(t,e){return t===e?Dt:ut(t)>=ut(e)?t>0?At:It:e>0?xt:Rt}function O(t,e,i){i||(i=Nt);var n=e[i[0]]-t[i[0]],s=e[i[1]]-t[i[1]];return Math.sqrt(n*n+s*s)}function P(t,e,i){i||(i=Nt);var n=e[i[0]]-t[i[0]],s=e[i[1]]-t[i[1]];return 180*Math.atan2(s,n)/Math.PI}function N(t,e){return P(e[1],e[0],$t)-P(t[1],t[0],$t)}function $(t,e){return O(e[0],e[1],$t)/O(t[0],t[1],$t)}function U(){this.evEl=Ft,this.evWin=Bt,this.allow=!0,this.pressed=!1,k.apply(this,arguments)}function F(){this.evEl=Vt,this.evWin=zt,k.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function B(){this.evTarget=Wt,this.evWin=Kt,this.started=!1,k.apply(this,arguments)}function H(t,e){var i=S(t.touches),n=S(t.changedTouches);return e&(Ct|_t)&&(i=y(i.concat(n),"identifier",!0)),[i,n]}function j(){this.evTarget=qt,this.targetIds={},k.apply(this,arguments)}function V(t,e){var i=S(t.touches),n=this.targetIds;if(e&(kt|wt)&&1===i.length)return n[i[0].identifier]=!0,[i,i];var s,o,a=S(t.changedTouches),r=[],l=this.target;if(o=i.filter(function(t){return f(t.target,l)}),e===kt)for(s=0;s<o.length;)n[o[s].identifier]=!0,s++;for(s=0;s<a.length;)n[a[s].identifier]&&r.push(a[s]),e&(Ct|_t)&&delete n[a[s].identifier],s++;return r.length?[y(o.concat(r),"identifier",!0),r]:void 0}function z(){k.apply(this,arguments);var t=c(this.handler,this);this.touch=new j(this.manager,t),this.mouse=new U(this.manager,t)}function G(t,e){this.manager=t,this.set(e)}function W(t){if(g(t,ee))return ee;var e=g(t,ie),i=g(t,ne);return e&&i?ie+" "+ne:e||i?e?ie:ne:g(t,te)?te:Zt}function K(t){this.id=T(),this.manager=null,this.options=l(t||{},this.defaults),this.options.enable=u(this.options.enable,!0),this.state=se,this.simultaneous={},this.requireFail=[]}function Y(t){return t&de?"cancel":t&re?"end":t&ae?"move":t&oe?"start":""}function q(t){return t==Rt?"down":t==xt?"up":t==At?"left":t==It?"right":""}function X(t,e){var i=e.manager;return i?i.get(t):t}function J(){K.apply(this,arguments)}function Q(){J.apply(this,arguments),this.pX=null,this.pY=null}function Z(){J.apply(this,arguments)}function tt(){K.apply(this,arguments),this._timer=null,this._input=null}function et(){J.apply(this,arguments)}function it(){J.apply(this,arguments)}function nt(){K.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function st(t,e){return e=e||{},e.recognizers=u(e.recognizers,st.defaults.preset),new ot(t,e)}function ot(t,e){e=e||{},this.options=l(e,st.defaults),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.element=t,this.input=w(this),this.touchAction=new G(this,this.options.touchAction),at(this,!0),a(e.recognizers,function(t){var e=this.add(new t[0](t[1]));t[2]&&e.recognizeWith(t[2]),t[3]&&e.requireFailure(t[3])},this)}function at(t,e){var i=t.element;a(t.options.cssProps,function(t,n){i.style[E(i.style,n)]=e?t:""})}function rt(t,i){var n=e.createEvent("Event");n.initEvent(t,!0,!0),n.gesture=i,i.target.dispatchEvent(n)}var lt=["","webkit","moz","MS","ms","o"],dt=e.createElement("div"),ct="function",ht=Math.round,ut=Math.abs,pt=Date.now,mt=1,ft=/mobile|tablet|ip(ad|hone|od)|android/i,gt="ontouchstart"in t,vt=E(t,"PointerEvent")!==n,bt=gt&&ft.test(navigator.userAgent),St="touch",yt="pen",Et="mouse",Tt="kinect",Lt=25,kt=1,wt=2,Ct=4,_t=8,Dt=1,At=2,It=4,xt=8,Rt=16,Mt=At|It,Ot=xt|Rt,Pt=Mt|Ot,Nt=["x","y"],$t=["clientX","clientY"];k.prototype={handler:function(){},init:function(){this.evEl&&p(this.element,this.evEl,this.domHandler),this.evTarget&&p(this.target,this.evTarget,this.domHandler),this.evWin&&p(L(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&m(this.element,this.evEl,this.domHandler),this.evTarget&&m(this.target,this.evTarget,this.domHandler),this.evWin&&m(L(this.element),this.evWin,this.domHandler)}};var Ut={mousedown:kt,mousemove:wt,mouseup:Ct},Ft="mousedown",Bt="mousemove mouseup";d(U,k,{handler:function(t){var e=Ut[t.type];e&kt&&0===t.button&&(this.pressed=!0),e&wt&&1!==t.which&&(e=Ct),this.pressed&&this.allow&&(e&Ct&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:Et,srcEvent:t}))}});var Ht={pointerdown:kt,pointermove:wt,pointerup:Ct,pointercancel:_t,pointerout:_t},jt={2:St,3:yt,4:Et,5:Tt},Vt="pointerdown",zt="pointermove pointerup pointercancel";t.MSPointerEvent&&(Vt="MSPointerDown",zt="MSPointerMove MSPointerUp MSPointerCancel"),d(F,k,{handler:function(t){var e=this.store,i=!1,n=t.type.toLowerCase().replace("ms",""),s=Ht[n],o=jt[t.pointerType]||t.pointerType,a=o==St,r=b(e,t.pointerId,"pointerId");s&kt&&(0===t.button||a)?r<0&&(e.push(t),r=e.length-1):s&(Ct|_t)&&(i=!0),r<0||(e[r]=t,this.callback(this.manager,s,{pointers:e,changedPointers:[t],pointerType:o,srcEvent:t}),i&&e.splice(r,1))}});var Gt={touchstart:kt,touchmove:wt,touchend:Ct,touchcancel:_t},Wt="touchstart",Kt="touchstart touchmove touchend touchcancel";d(B,k,{handler:function(t){var e=Gt[t.type];if(e===kt&&(this.started=!0),this.started){var i=H.call(this,t,e);e&(Ct|_t)&&i[0].length-i[1].length===0&&(this.started=!1),this.callback(this.manager,e,{pointers:i[0],changedPointers:i[1],pointerType:St,srcEvent:t})}}});var Yt={touchstart:kt,touchmove:wt,touchend:Ct,touchcancel:_t},qt="touchstart touchmove touchend touchcancel";d(j,k,{handler:function(t){var e=Yt[t.type],i=V.call(this,t,e);i&&this.callback(this.manager,e,{pointers:i[0],changedPointers:i[1],pointerType:St,srcEvent:t})}}),d(z,k,{handler:function(t,e,i){var n=i.pointerType==St,s=i.pointerType==Et;if(n)this.mouse.allow=!1;else if(s&&!this.mouse.allow)return;e&(Ct|_t)&&(this.mouse.allow=!0),this.callback(t,e,i)},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var Xt=E(dt.style,"touchAction"),Jt=Xt!==n,Qt="compute",Zt="auto",te="manipulation",ee="none",ie="pan-x",ne="pan-y";G.prototype={set:function(t){t==Qt&&(t=this.compute()),Jt&&(this.manager.element.style[Xt]=t),this.actions=t.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var t=[];return a(this.manager.recognizers,function(e){h(e.options.enable,[e])&&(t=t.concat(e.getTouchAction()))}),W(t.join(" "))},preventDefaults:function(t){if(!Jt){var e=t.srcEvent,i=t.offsetDirection;if(this.manager.session.prevented)return void e.preventDefault();var n=this.actions,s=g(n,ee),o=g(n,ne),a=g(n,ie);return s||o&&i&Mt||a&&i&Ot?this.preventSrc(e):void 0}},preventSrc:function(t){this.manager.session.prevented=!0,t.preventDefault()}};var se=1,oe=2,ae=4,re=8,le=re,de=16,ce=32;K.prototype={defaults:{},set:function(t){return r(this.options,t),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(t){if(o(t,"recognizeWith",this))return this;var e=this.simultaneous;return t=X(t,this),e[t.id]||(e[t.id]=t,t.recognizeWith(this)),this},dropRecognizeWith:function(t){return o(t,"dropRecognizeWith",this)?this:(t=X(t,this),delete this.simultaneous[t.id],this)},requireFailure:function(t){if(o(t,"requireFailure",this))return this;var e=this.requireFail;return t=X(t,this),b(e,t)===-1&&(e.push(t),t.requireFailure(this)),this},dropRequireFailure:function(t){if(o(t,"dropRequireFailure",this))return this;t=X(t,this);var e=b(this.requireFail,t);return e>-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){function e(e){i.manager.emit(i.options.event+(e?Y(n):""),t)}var i=this,n=this.state;n<re&&e(!0),e(),n>=re&&e(!0)},tryEmit:function(t){return this.canEmit()?this.emit(t):void(this.state=ce)},canEmit:function(){for(var t=0;t<this.requireFail.length;){if(!(this.requireFail[t].state&(ce|se)))return!1;t++}return!0},recognize:function(t){var e=r({},t);return h(this.options.enable,[this,e])?(this.state&(le|de|ce)&&(this.state=se),this.state=this.process(e),void(this.state&(oe|ae|re|de)&&this.tryEmit(e))):(this.reset(),void(this.state=ce))},process:function(){},getTouchAction:function(){},reset:function(){}},d(J,K,{defaults:{pointers:1},attrTest:function(t){var e=this.options.pointers;return 0===e||t.pointers.length===e},process:function(t){var e=this.state,i=t.eventType,n=e&(oe|ae),s=this.attrTest(t);return n&&(i&_t||!s)?e|de:n||s?i&Ct?e|re:e&oe?e|ae:oe:ce}}),d(Q,J,{defaults:{event:"pan",threshold:10,pointers:1,direction:Pt},getTouchAction:function(){var t=this.options.direction,e=[];return t&Mt&&e.push(ne),t&Ot&&e.push(ie),e},directionTest:function(t){var e=this.options,i=!0,n=t.distance,s=t.direction,o=t.deltaX,a=t.deltaY;return s&e.direction||(e.direction&Mt?(s=0===o?Dt:o<0?At:It,i=o!=this.pX,n=Math.abs(t.deltaX)):(s=0===a?Dt:a<0?xt:Rt,i=a!=this.pY,n=Math.abs(t.deltaY))),t.direction=s,i&&n>e.threshold&&s&e.direction},attrTest:function(t){return J.prototype.attrTest.call(this,t)&&(this.state&oe||!(this.state&oe)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=q(t.direction);e&&this.manager.emit(this.options.event+e,t),this._super.emit.call(this,t)}}),d(Z,J,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[ee]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||this.state&oe)},emit:function(t){if(this._super.emit.call(this,t),1!==t.scale){var e=t.scale<1?"in":"out";this.manager.emit(this.options.event+e,t)}}}),d(tt,K,{defaults:{event:"press",pointers:1,time:500,threshold:5},getTouchAction:function(){return[Zt]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,n=t.distance<e.threshold,o=t.deltaTime>e.time;if(this._input=t,!n||!i||t.eventType&(Ct|_t)&&!o)this.reset();else if(t.eventType&kt)this.reset(),this._timer=s(function(){this.state=le,this.tryEmit()},e.time,this);else if(t.eventType&Ct)return le;return ce},reset:function(){clearTimeout(this._timer)},emit:function(t){this.state===le&&(t&&t.eventType&Ct?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=pt(),this.manager.emit(this.options.event,this._input)))}}),d(et,J,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[ee]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||this.state&oe)}}),d(it,J,{defaults:{event:"swipe",threshold:10,velocity:.65,direction:Mt|Ot,pointers:1},getTouchAction:function(){return Q.prototype.getTouchAction.call(this)},attrTest:function(t){var e,i=this.options.direction;return i&(Mt|Ot)?e=t.velocity:i&Mt?e=t.velocityX:i&Ot&&(e=t.velocityY),this._super.attrTest.call(this,t)&&i&t.direction&&t.distance>this.options.threshold&&ut(e)>this.options.velocity&&t.eventType&Ct},emit:function(t){var e=q(t.direction);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}}),d(nt,K,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:2,posThreshold:10},getTouchAction:function(){return[te]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,n=t.distance<e.threshold,o=t.deltaTime<e.time;if(this.reset(),t.eventType&kt&&0===this.count)return this.failTimeout();if(n&&o&&i){if(t.eventType!=Ct)return this.failTimeout();var a=!this.pTime||t.timeStamp-this.pTime<e.interval,r=!this.pCenter||O(this.pCenter,t.center)<e.posThreshold;this.pTime=t.timeStamp,this.pCenter=t.center,r&&a?this.count+=1:this.count=1,this._input=t;var l=this.count%e.taps;if(0===l)return this.hasRequireFailures()?(this._timer=s(function(){this.state=le,this.tryEmit()},e.interval,this),oe):le}return ce},failTimeout:function(){return this._timer=s(function(){this.state=ce},this.options.interval,this),ce},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==le&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),st.VERSION="2.0.4",st.defaults={domEvents:!1,touchAction:Qt,enable:!0,inputTarget:null,inputClass:null,preset:[[et,{enable:!1}],[Z,{enable:!1},["rotate"]],[it,{direction:Mt}],[Q,{direction:Mt},["swipe"]],[nt],[nt,{event:"doubletap",taps:2},["tap"]],[tt]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};var he=1,ue=2;ot.prototype={set:function(t){return r(this.options,t),t.touchAction&&this.touchAction.update(),t.inputTarget&&(this.input.destroy(),this.input.target=t.inputTarget,this.input.init()),this},stop:function(t){this.session.stopped=t?ue:he},recognize:function(t){var e=this.session;if(!e.stopped){this.touchAction.preventDefaults(t);var i,n=this.recognizers,s=e.curRecognizer;(!s||s&&s.state&le)&&(s=e.curRecognizer=null);for(var o=0;o<n.length;)i=n[o],e.stopped===ue||s&&i!=s&&!i.canRecognizeWith(s)?i.reset():i.recognize(t),!s&&i.state&(oe|ae|re)&&(s=e.curRecognizer=i),o++}},get:function(t){if(t instanceof K)return t;for(var e=this.recognizers,i=0;i<e.length;i++)if(e[i].options.event==t)return e[i];return null},add:function(t){if(o(t,"add",this))return this;var e=this.get(t.options.event);return e&&this.remove(e),this.recognizers.push(t),t.manager=this,this.touchAction.update(),t},remove:function(t){if(o(t,"remove",this))return this;var e=this.recognizers;return t=this.get(t),e.splice(b(e,t),1),this.touchAction.update(),this},on:function(t,e){var i=this.handlers;return a(v(t),function(t){i[t]=i[t]||[],i[t].push(e)}),this},off:function(t,e){var i=this.handlers;return a(v(t),function(t){e?i[t].splice(b(i[t],e),1):delete i[t]}),this},emit:function(t,e){this.options.domEvents&&rt(t,e);var i=this.handlers[t]&&this.handlers[t].slice();if(i&&i.length){e.type=t,e.preventDefault=function(){e.srcEvent.preventDefault()};for(var n=0;n<i.length;)i[n](e),n++}},destroy:function(){this.element&&at(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},r(st,{INPUT_START:kt,INPUT_MOVE:wt,INPUT_END:Ct,INPUT_CANCEL:_t,STATE_POSSIBLE:se,STATE_BEGAN:oe,STATE_CHANGED:ae,STATE_ENDED:re,STATE_RECOGNIZED:le,STATE_CANCELLED:de,STATE_FAILED:ce,DIRECTION_NONE:Dt,DIRECTION_LEFT:At,DIRECTION_RIGHT:It,DIRECTION_UP:xt,DIRECTION_DOWN:Rt,DIRECTION_HORIZONTAL:Mt,DIRECTION_VERTICAL:Ot,DIRECTION_ALL:Pt,Manager:ot,Input:k,TouchAction:G,TouchInput:j,MouseInput:U,PointerEventInput:F,TouchMouseInput:z,SingleTouchInput:B,Recognizer:K,AttrRecognizer:J,Tap:nt,Pan:Q,Swipe:it,Pinch:Z,Rotate:et,Press:tt,on:p,off:m,each:a,merge:l,extend:r,inherit:d,bindFn:c,prefixed:E}),typeof define==ct&&define.amd?define(function(){return st}):"undefined"!=typeof module&&module.exports?module.exports=st:t[i]=st}(window,document,"Hammer");var CryptoJS=CryptoJS||function(t,e){var i={},n=i.lib={},s=function(){},o=n.Base={extend:function(t){s.prototype=this;var e=new s;return t&&e.mixIn(t),e.hasOwnProperty("init")||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},a=n.WordArray=o.extend({init:function(t,i){t=this.words=t||[],this.sigBytes=i!=e?i:4*t.length},toString:function(t){return(t||l).stringify(this)},concat:function(t){var e=this.words,i=t.words,n=this.sigBytes;if(t=t.sigBytes,this.clamp(),n%4)for(var s=0;s<t;s++)e[n+s>>>2]|=(i[s>>>2]>>>24-8*(s%4)&255)<<24-8*((n+s)%4);else if(65535<i.length)for(s=0;s<t;s+=4)e[n+s>>>2]=i[s>>>2];else e.push.apply(e,i);return this.sigBytes+=t,this},clamp:function(){var e=this.words,i=this.sigBytes;e[i>>>2]&=4294967295<<32-8*(i%4),e.length=t.ceil(i/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var i=[],n=0;n<e;n+=4)i.push(4294967296*t.random()|0);return new a.init(i,e)}}),r=i.enc={},l=r.Hex={stringify:function(t){var e=t.words;t=t.sigBytes;for(var i=[],n=0;n<t;n++){var s=e[n>>>2]>>>24-8*(n%4)&255;i.push((s>>>4).toString(16)),i.push((15&s).toString(16))}return i.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n<e;n+=2)i[n>>>3]|=parseInt(t.substr(n,2),16)<<24-4*(n%8);return new a.init(i,e/2)}},d=r.Latin1={stringify:function(t){var e=t.words;t=t.sigBytes;for(var i=[],n=0;n<t;n++)i.push(String.fromCharCode(e[n>>>2]>>>24-8*(n%4)&255));return i.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n<e;n++)i[n>>>2]|=(255&t.charCodeAt(n))<<24-8*(n%4);return new a.init(i,e)}},c=r.Utf8={stringify:function(t){try{return decodeURIComponent(escape(d.stringify(t)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(t){return d.parse(unescape(encodeURIComponent(t)))}},h=n.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=c.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var i=this._data,n=i.words,s=i.sigBytes,o=this.blockSize,r=s/(4*o),r=e?t.ceil(r):t.max((0|r)-this._minBufferSize,0);if(e=r*o,s=t.min(4*e,s),e){for(var l=0;l<e;l+=o)this._doProcessBlock(n,l);l=n.splice(0,e),i.sigBytes-=s}return new a.init(l,s)},clone:function(){var t=o.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});n.Hasher=h.extend({cfg:o.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,i){return new t.init(i).finalize(e)}},_createHmacHelper:function(t){return function(e,i){return new u.HMAC.init(t,i).finalize(e)}}});var u=i.algo={};return i}(Math);!function(t){function e(t,e,i,n,s,o,a){return t=t+(e&i|~e&n)+s+a,(t<<o|t>>>32-o)+e}function i(t,e,i,n,s,o,a){return t=t+(e&n|i&~n)+s+a,(t<<o|t>>>32-o)+e}function n(t,e,i,n,s,o,a){return t=t+(e^i^n)+s+a,(t<<o|t>>>32-o)+e}function s(t,e,i,n,s,o,a){return t=t+(i^(e|~n))+s+a,(t<<o|t>>>32-o)+e}for(var o=CryptoJS,a=o.lib,r=a.WordArray,l=a.Hasher,a=o.algo,d=[],c=0;64>c;c++)d[c]=4294967296*t.abs(t.sin(c+1))|0;a=a.MD5=l.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,o){for(var a=0;16>a;a++){var r=o+a,l=t[r];
t[r]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}var a=this._hash.words,r=t[o+0],l=t[o+1],c=t[o+2],h=t[o+3],u=t[o+4],p=t[o+5],m=t[o+6],f=t[o+7],g=t[o+8],v=t[o+9],b=t[o+10],S=t[o+11],y=t[o+12],E=t[o+13],T=t[o+14],L=t[o+15],k=a[0],w=a[1],C=a[2],_=a[3],k=e(k,w,C,_,r,7,d[0]),_=e(_,k,w,C,l,12,d[1]),C=e(C,_,k,w,c,17,d[2]),w=e(w,C,_,k,h,22,d[3]),k=e(k,w,C,_,u,7,d[4]),_=e(_,k,w,C,p,12,d[5]),C=e(C,_,k,w,m,17,d[6]),w=e(w,C,_,k,f,22,d[7]),k=e(k,w,C,_,g,7,d[8]),_=e(_,k,w,C,v,12,d[9]),C=e(C,_,k,w,b,17,d[10]),w=e(w,C,_,k,S,22,d[11]),k=e(k,w,C,_,y,7,d[12]),_=e(_,k,w,C,E,12,d[13]),C=e(C,_,k,w,T,17,d[14]),w=e(w,C,_,k,L,22,d[15]),k=i(k,w,C,_,l,5,d[16]),_=i(_,k,w,C,m,9,d[17]),C=i(C,_,k,w,S,14,d[18]),w=i(w,C,_,k,r,20,d[19]),k=i(k,w,C,_,p,5,d[20]),_=i(_,k,w,C,b,9,d[21]),C=i(C,_,k,w,L,14,d[22]),w=i(w,C,_,k,u,20,d[23]),k=i(k,w,C,_,v,5,d[24]),_=i(_,k,w,C,T,9,d[25]),C=i(C,_,k,w,h,14,d[26]),w=i(w,C,_,k,g,20,d[27]),k=i(k,w,C,_,E,5,d[28]),_=i(_,k,w,C,c,9,d[29]),C=i(C,_,k,w,f,14,d[30]),w=i(w,C,_,k,y,20,d[31]),k=n(k,w,C,_,p,4,d[32]),_=n(_,k,w,C,g,11,d[33]),C=n(C,_,k,w,S,16,d[34]),w=n(w,C,_,k,T,23,d[35]),k=n(k,w,C,_,l,4,d[36]),_=n(_,k,w,C,u,11,d[37]),C=n(C,_,k,w,f,16,d[38]),w=n(w,C,_,k,b,23,d[39]),k=n(k,w,C,_,E,4,d[40]),_=n(_,k,w,C,r,11,d[41]),C=n(C,_,k,w,h,16,d[42]),w=n(w,C,_,k,m,23,d[43]),k=n(k,w,C,_,v,4,d[44]),_=n(_,k,w,C,y,11,d[45]),C=n(C,_,k,w,L,16,d[46]),w=n(w,C,_,k,c,23,d[47]),k=s(k,w,C,_,r,6,d[48]),_=s(_,k,w,C,f,10,d[49]),C=s(C,_,k,w,T,15,d[50]),w=s(w,C,_,k,p,21,d[51]),k=s(k,w,C,_,y,6,d[52]),_=s(_,k,w,C,h,10,d[53]),C=s(C,_,k,w,b,15,d[54]),w=s(w,C,_,k,l,21,d[55]),k=s(k,w,C,_,g,6,d[56]),_=s(_,k,w,C,L,10,d[57]),C=s(C,_,k,w,m,15,d[58]),w=s(w,C,_,k,E,21,d[59]),k=s(k,w,C,_,u,6,d[60]),_=s(_,k,w,C,S,10,d[61]),C=s(C,_,k,w,c,15,d[62]),w=s(w,C,_,k,v,21,d[63]);a[0]=a[0]+k|0,a[1]=a[1]+w|0,a[2]=a[2]+C|0,a[3]=a[3]+_|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,s=8*e.sigBytes;i[s>>>5]|=128<<24-s%32;var o=t.floor(n/4294967296);for(i[(s+64>>>9<<4)+15]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),i[(s+64>>>9<<4)+14]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(i.length+1),this._process(),e=this._hash,i=e.words,n=0;4>n;n++)s=i[n],i[n]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8);return e},clone:function(){var t=l.clone.call(this);return t._hash=this._hash.clone(),t}}),o.MD5=l._createHelper(a),o.HmacMD5=l._createHmacHelper(a)}(Math),function(){function t(t){var i={r:0,g:0,b:0},s=1,a=!1,r=!1;return"string"==typeof t&&(t=R(t)),"object"==typeof t&&(t.hasOwnProperty("r")&&t.hasOwnProperty("g")&&t.hasOwnProperty("b")?(i=e(t.r,t.g,t.b),a=!0,r="%"===String(t.r).substr(-1)?"prgb":"rgb"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("v")?(t.s=A(t.s),t.v=A(t.v),i=o(t.h,t.s,t.v),a=!0,r="hsv"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("l")&&(t.s=A(t.s),t.l=A(t.l),i=n(t.h,t.s,t.l),a=!0,r="hsl"),t.hasOwnProperty("a")&&(s=t.a)),s=T(s),{ok:a,format:t.format||r,r:U(255,F(i.r,0)),g:U(255,F(i.g,0)),b:U(255,F(i.b,0)),a:s}}function e(t,e,i){return{r:255*L(t,255),g:255*L(e,255),b:255*L(i,255)}}function i(t,e,i){t=L(t,255),e=L(e,255),i=L(i,255);var n,s,o=F(t,e,i),a=U(t,e,i),r=(o+a)/2;if(o==a)n=s=0;else{var l=o-a;switch(s=r>.5?l/(2-o-a):l/(o+a),o){case t:n=(e-i)/l+(e<i?6:0);break;case e:n=(i-t)/l+2;break;case i:n=(t-e)/l+4}n/=6}return{h:n,s:s,l:r}}function n(t,e,i){function n(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}var s,o,a;if(t=L(t,360),e=L(e,100),i=L(i,100),0===e)s=o=a=i;else{var r=i<.5?i*(1+e):i+e-i*e,l=2*i-r;s=n(l,r,t+1/3),o=n(l,r,t),a=n(l,r,t-1/3)}return{r:255*s,g:255*o,b:255*a}}function s(t,e,i){t=L(t,255),e=L(e,255),i=L(i,255);var n,s,o=F(t,e,i),a=U(t,e,i),r=o,l=o-a;if(s=0===o?0:l/o,o==a)n=0;else{switch(o){case t:n=(e-i)/l+(e<i?6:0);break;case e:n=(i-t)/l+2;break;case i:n=(t-e)/l+4}n/=6}return{h:n,s:s,v:r}}function o(t,e,i){t=6*L(t,360),e=L(e,100),i=L(i,100);var n=N.floor(t),s=t-n,o=i*(1-e),a=i*(1-s*e),r=i*(1-(1-s)*e),l=n%6,d=[i,a,o,o,r,i][l],c=[r,i,i,a,o,o][l],h=[o,o,r,i,i,a][l];return{r:255*d,g:255*c,b:255*h}}function a(t,e,i,n){var s=[D($(t).toString(16)),D($(e).toString(16)),D($(i).toString(16))];return n&&s[0].charAt(0)==s[0].charAt(1)&&s[1].charAt(0)==s[1].charAt(1)&&s[2].charAt(0)==s[2].charAt(1)?s[0].charAt(0)+s[1].charAt(0)+s[2].charAt(0):s.join("")}function r(t,e,i,n){var s=[D(I(n)),D($(t).toString(16)),D($(e).toString(16)),D($(i).toString(16))];return s.join("")}function l(t,e){e=0===e?0:e||10;var i=H(t).toHsl();return i.s-=e/100,i.s=k(i.s),H(i)}function d(t,e){e=0===e?0:e||10;var i=H(t).toHsl();return i.s+=e/100,i.s=k(i.s),H(i)}function c(t){return H(t).desaturate(100)}function h(t,e){e=0===e?0:e||10;var i=H(t).toHsl();return i.l+=e/100,i.l=k(i.l),H(i)}function u(t,e){e=0===e?0:e||10;var i=H(t).toRgb();return i.r=F(0,U(255,i.r-$(255*-(e/100)))),i.g=F(0,U(255,i.g-$(255*-(e/100)))),i.b=F(0,U(255,i.b-$(255*-(e/100)))),H(i)}function p(t,e){e=0===e?0:e||10;var i=H(t).toHsl();return i.l-=e/100,i.l=k(i.l),H(i)}function m(t,e){var i=H(t).toHsl(),n=($(i.h)+e)%360;return i.h=n<0?360+n:n,H(i)}function f(t){var e=H(t).toHsl();return e.h=(e.h+180)%360,H(e)}function g(t){var e=H(t).toHsl(),i=e.h;return[H(t),H({h:(i+120)%360,s:e.s,l:e.l}),H({h:(i+240)%360,s:e.s,l:e.l})]}function v(t){var e=H(t).toHsl(),i=e.h;return[H(t),H({h:(i+90)%360,s:e.s,l:e.l}),H({h:(i+180)%360,s:e.s,l:e.l}),H({h:(i+270)%360,s:e.s,l:e.l})]}function b(t){var e=H(t).toHsl(),i=e.h;return[H(t),H({h:(i+72)%360,s:e.s,l:e.l}),H({h:(i+216)%360,s:e.s,l:e.l})]}function S(t,e,i){e=e||6,i=i||30;var n=H(t).toHsl(),s=360/i,o=[H(t)];for(n.h=(n.h-(s*e>>1)+720)%360;--e;)n.h=(n.h+s)%360,o.push(H(n));return o}function y(t,e){e=e||6;for(var i=H(t).toHsv(),n=i.h,s=i.s,o=i.v,a=[],r=1/e;e--;)a.push(H({h:n,s:s,v:o})),o=(o+r)%1;return a}function E(t){var e={};for(var i in t)t.hasOwnProperty(i)&&(e[t[i]]=i);return e}function T(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function L(t,e){C(t)&&(t="100%");var i=_(t);return t=U(e,F(0,parseFloat(t))),i&&(t=parseInt(t*e,10)/100),N.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function k(t){return U(1,F(0,t))}function w(t){return parseInt(t,16)}function C(t){return"string"==typeof t&&t.indexOf(".")!=-1&&1===parseFloat(t)}function _(t){return"string"==typeof t&&t.indexOf("%")!=-1}function D(t){return 1==t.length?"0"+t:""+t}function A(t){return t<=1&&(t=100*t+"%"),t}function I(t){return Math.round(255*parseFloat(t)).toString(16)}function x(t){return w(t)/255}function R(t){t=t.replace(M,"").replace(O,"").toLowerCase();var e=!1;if(j[t])t=j[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var i;return(i=z.rgb.exec(t))?{r:i[1],g:i[2],b:i[3]}:(i=z.rgba.exec(t))?{r:i[1],g:i[2],b:i[3],a:i[4]}:(i=z.hsl.exec(t))?{h:i[1],s:i[2],l:i[3]}:(i=z.hsla.exec(t))?{h:i[1],s:i[2],l:i[3],a:i[4]}:(i=z.hsv.exec(t))?{h:i[1],s:i[2],v:i[3]}:(i=z.hex8.exec(t))?{a:x(i[1]),r:w(i[2]),g:w(i[3]),b:w(i[4]),format:e?"name":"hex8"}:(i=z.hex6.exec(t))?{r:w(i[1]),g:w(i[2]),b:w(i[3]),format:e?"name":"hex"}:!!(i=z.hex3.exec(t))&&{r:w(i[1]+""+i[1]),g:w(i[2]+""+i[2]),b:w(i[3]+""+i[3]),format:e?"name":"hex"}}var M=/^[\s,#]+/,O=/\s+$/,P=0,N=Math,$=N.round,U=N.min,F=N.max,B=N.random,H=function e(i,n){if(i=i?i:"",n=n||{},i instanceof e)return i;if(!(this instanceof e))return new e(i,n);var s=t(i);this._r=s.r,this._g=s.g,this._b=s.b,this._a=s.a,this._roundA=$(100*this._a)/100,this._format=n.format||s.format,this._gradientType=n.gradientType,this._r<1&&(this._r=$(this._r)),this._g<1&&(this._g=$(this._g)),this._b<1&&(this._b=$(this._b)),this._ok=s.ok,this._tc_id=P++};H.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},setAlpha:function(t){return this._a=T(t),this._roundA=$(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=$(360*t.h),i=$(100*t.s),n=$(100*t.v);return 1==this._a?"hsv("+e+", "+i+"%, "+n+"%)":"hsva("+e+", "+i+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=i(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=i(this._r,this._g,this._b),e=$(360*t.h),n=$(100*t.s),s=$(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+s+"%)":"hsla("+e+", "+n+"%, "+s+"%, "+this._roundA+")"},toHex:function(t){return a(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return r(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:$(this._r),g:$(this._g),b:$(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+$(this._r)+", "+$(this._g)+", "+$(this._b)+")":"rgba("+$(this._r)+", "+$(this._g)+", "+$(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:$(100*L(this._r,255))+"%",g:$(100*L(this._g,255))+"%",b:$(100*L(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+$(100*L(this._r,255))+"%, "+$(100*L(this._g,255))+"%, "+$(100*L(this._b,255))+"%)":"rgba("+$(100*L(this._r,255))+"%, "+$(100*L(this._g,255))+"%, "+$(100*L(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(V[a(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+r(this._r,this._g,this._b,this._a),i=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var s=H(t);i=s.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+i+")"},toString:function(t){var e=!!t;t=t||this._format;var i=!1,n=this._a<1&&this._a>=0,s=!e&&n&&("hex"===t||"hex6"===t||"hex3"===t||"name"===t);return s?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(i=this.toRgbString()),"prgb"===t&&(i=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(i=this.toHexString()),"hex3"===t&&(i=this.toHexString(!0)),"hex8"===t&&(i=this.toHex8String()),"name"===t&&(i=this.toName()),"hsl"===t&&(i=this.toHslString()),"hsv"===t&&(i=this.toHsvString()),i||this.toHexString())},_applyModification:function(t,e){var i=t.apply(null,[this].concat([].slice.call(e)));return this._r=i._r,this._g=i._g,this._b=i._b,this.setAlpha(i._a),this},lighten:function(){return this._applyModification(h,arguments)},brighten:function(){return this._applyModification(u,arguments)},darken:function(){return this._applyModification(p,arguments)},desaturate:function(){return this._applyModification(l,arguments)},saturate:function(){return this._applyModification(d,arguments)},greyscale:function(){return this._applyModification(c,arguments)},spin:function(){return this._applyModification(m,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(S,arguments)},complement:function(){return this._applyCombination(f,arguments)},monochromatic:function(){return this._applyCombination(y,arguments)},splitcomplement:function(){return this._applyCombination(b,arguments)},triad:function(){return this._applyCombination(g,arguments)},tetrad:function(){return this._applyCombination(v,arguments)}},H.fromRatio=function(t,e){if("object"==typeof t){var i={};for(var n in t)t.hasOwnProperty(n)&&("a"===n?i[n]=t[n]:i[n]=A(t[n]));t=i}return H(t,e)},H.equals=function(t,e){return!(!t||!e)&&H(t).toRgbString()==H(e).toRgbString()},H.random=function(){return H.fromRatio({r:B(),g:B(),b:B()})},H.mix=function(t,e,i){i=0===i?0:i||50;var n,s=H(t).toRgb(),o=H(e).toRgb(),a=i/100,r=2*a-1,l=o.a-s.a;n=r*l==-1?r:(r+l)/(1+r*l),n=(n+1)/2;var d=1-n,c={r:o.r*n+s.r*d,g:o.g*n+s.g*d,b:o.b*n+s.b*d,a:o.a*a+s.a*(1-a)};return H(c)},H.readability=function(t,e){var i=H(t),n=H(e),s=i.toRgb(),o=n.toRgb(),a=i.getBrightness(),r=n.getBrightness(),l=Math.max(s.r,o.r)-Math.min(s.r,o.r)+Math.max(s.g,o.g)-Math.min(s.g,o.g)+Math.max(s.b,o.b)-Math.min(s.b,o.b);return{brightness:Math.abs(a-r),color:l}},H.isReadable=function(t,e){var i=H.readability(t,e);return i.brightness>125&&i.color>500},H.mostReadable=function(t,e){for(var i=null,n=0,s=!1,o=0;o<e.length;o++){var a=H.readability(t,e[o]),r=a.brightness>125&&a.color>500,l=3*(a.brightness/125)+a.color/500;(r&&!s||r&&s&&l>n||!r&&!s&&l>n)&&(s=r,n=l,i=H(e[o]))}return i};var j=H.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},V=H.hexNames=E(j),z=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",i="(?:"+e+")|(?:"+t+")",n="[\\s|\\(]+("+i+")[,|\\s]+("+i+")[,|\\s]+("+i+")\\s*\\)?",s="[\\s|\\(]+("+i+")[,|\\s]+("+i+")[,|\\s]+("+i+")[,|\\s]+("+i+")\\s*\\)?";return{rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+s),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+s),hsv:new RegExp("hsv"+n),hex3:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof module&&module.exports?module.exports=H:"function"==typeof define&&define.amd?define(function(){return H}):window.tinycolor=H}(),function(t,e){function i(t){return t.call.apply(t.bind,arguments)}function n(t,e){if(!t)throw Error();if(2<arguments.length){var i=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,i),t.apply(e,n)}}return function(){return t.apply(e,arguments)}}function s(){return s=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?i:n,s.apply(null,arguments)}function o(t,e){this.J=t,this.t=e||t,this.C=this.t.document}function a(t,i,n){t=t.C.getElementsByTagName(i)[0],t||(t=e.documentElement),t&&t.lastChild&&t.insertBefore(n,t.lastChild)}function r(t,e){function i(){t.C.body?e():setTimeout(i,0)}i()}function l(t,e,i){e=e||[],i=i||[];for(var n=t.className.split(/\s+/),s=0;s<e.length;s+=1){for(var o=!1,a=0;a<n.length;a+=1)if(e[s]===n[a]){o=!0;break}o||n.push(e[s])}for(e=[],s=0;s<n.length;s+=1){for(o=!1,a=0;a<i.length;a+=1)if(n[s]===i[a]){o=!0;break}o||e.push(n[s])}t.className=e.join(" ").replace(/\s+/g," ").replace(/^\s+|\s+$/,"")}function d(t,e){for(var i=t.className.split(/\s+/),n=0,s=i.length;n<s;n++)if(i[n]==e)return!0;return!1}function c(t){if("string"==typeof t.ma)return t.ma;var e=t.t.location.protocol;return"about:"==e&&(e=t.J.location.protocol),"https:"==e?"https:":"http:"}function h(t,e){var i=t.createElement("link",{rel:"stylesheet",href:e}),n=!1;i.onload=function(){n||(n=!0)},i.onerror=function(){n||(n=!0)},a(t,"head",i)}function u(e,i,n,s){var o=e.C.getElementsByTagName("head")[0];if(o){var a=e.createElement("script",{src:i}),r=!1;return a.onload=a.onreadystatechange=function(){r||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState||(r=!0,n&&n(null),a.onload=a.onreadystatechange=null,"HEAD"==a.parentNode.tagName&&o.removeChild(a))},o.appendChild(a),t.setTimeout(function(){r||(r=!0,n&&n(Error("Script load timeout")))},s||5e3),a}return null}function p(t,e){this.X=t,this.fa=e}function m(t,e,i,n){this.c=null!=t?t:null,this.g=null!=e?e:null,this.A=null!=i?i:null,this.e=null!=n?n:null}function f(t){t=J.exec(t);var e=null,i=null,n=null,s=null;return t&&(null!==t[1]&&t[1]&&(e=parseInt(t[1],10)),null!==t[2]&&t[2]&&(i=parseInt(t[2],10)),null!==t[3]&&t[3]&&(n=parseInt(t[3],10)),null!==t[4]&&t[4]&&(s=/^[0-9]+$/.test(t[4])?parseInt(t[4],10):t[4])),new m(e,i,n,s)}function g(t,e,i,n,s,o,a,r){this.M=t,this.k=r}function v(t){this.a=t}function b(t){var e=E(t.a,/(iPod|iPad|iPhone|Android|Windows Phone|BB\d{2}|BlackBerry)/,1);return""!=e?(/BB\d{2}/.test(e)&&(e="BlackBerry"),e):(t=E(t.a,/(Linux|Mac_PowerPC|Macintosh|Windows|CrOS|PlayStation|CrKey)/,1),""!=t?("Mac_PowerPC"==t?t="Macintosh":"PlayStation"==t&&(t="Linux"),t):"Unknown")}function S(t){var e=E(t.a,/(OS X|Windows NT|Android) ([^;)]+)/,2);if(e||(e=E(t.a,/Windows Phone( OS)? ([^;)]+)/,2))||(e=E(t.a,/(iPhone )?OS ([\d_]+)/,2)))return e;if(e=E(t.a,/(?:Linux|CrOS|CrKey) ([^;)]+)/,1))for(var e=e.split(/\s/),i=0;i<e.length;i+=1)if(/^[\d\._]+$/.test(e[i]))return e[i];return(t=E(t.a,/(BB\d{2}|BlackBerry).*?Version\/([^\s]*)/,2))?t:"Unknown"}function y(t){var e=b(t),i=f(S(t)),n=f(E(t.a,/AppleWeb(?:K|k)it\/([\d\.\+]+)/,1)),s="Unknown",o=new m,o="Unknown",a=!1;return/OPR\/[\d.]+/.test(t.a)?s="Opera":-1!=t.a.indexOf("Chrome")||-1!=t.a.indexOf("CrMo")||-1!=t.a.indexOf("CriOS")?s="Chrome":/Silk\/\d/.test(t.a)?s="Silk":"BlackBerry"==e||"Android"==e?s="BuiltinBrowser":-1!=t.a.indexOf("PhantomJS")?s="PhantomJS":-1!=t.a.indexOf("Safari")?s="Safari":-1!=t.a.indexOf("AdobeAIR")?s="AdobeAIR":-1!=t.a.indexOf("PlayStation")&&(s="BuiltinBrowser"),"BuiltinBrowser"==s?o="Unknown":"Silk"==s?o=E(t.a,/Silk\/([\d\._]+)/,1):"Chrome"==s?o=E(t.a,/(Chrome|CrMo|CriOS)\/([\d\.]+)/,2):-1!=t.a.indexOf("Version/")?o=E(t.a,/Version\/([\d\.\w]+)/,1):"AdobeAIR"==s?o=E(t.a,/AdobeAIR\/([\d\.]+)/,1):"Opera"==s?o=E(t.a,/OPR\/([\d.]+)/,1):"PhantomJS"==s&&(o=E(t.a,/PhantomJS\/([\d.]+)/,1)),o=f(o),a="AdobeAIR"==s?2<o.c||2==o.c&&5<=o.g:"BlackBerry"==e?10<=i.c:"Android"==e?2<i.c||2==i.c&&1<i.g:526<=n.c||525<=n.c&&13<=n.g,new g(s,0,0,0,0,0,0,new p(a,536>n.c||536==n.c&&11>n.g))}function E(t,e,i){return(t=t.match(e))&&t[i]?t[i]:""}function T(t){this.la=t||"-"}function L(t,e){this.M=t,this.Y=4,this.N="n";var i=(e||"n4").match(/^([nio])([1-9])$/i);i&&(this.N=i[1],this.Y=parseInt(i[2],10))}function k(t){return t.N+t.Y}function w(t){var e=4,i="n",n=null;return t&&((n=t.match(/(normal|oblique|italic)/i))&&n[1]&&(i=n[1].substr(0,1).toLowerCase()),(n=t.match(/([1-9]00|normal|bold)/i))&&n[1]&&(/bold/i.test(n[1])?e=7:/[1-9]00/.test(n[1])&&(e=parseInt(n[1].substr(0,1),10)))),i+e}function C(t,e){this.d=t,this.p=t.t.document.documentElement,this.P=e,this.j="wf",this.h=new T("-"),this.ga=!1!==e.events,this.B=!1!==e.classes}function _(t){if(t.B){var e=d(t.p,t.h.e(t.j,"active")),i=[],n=[t.h.e(t.j,"loading")];e||i.push(t.h.e(t.j,"inactive")),l(t.p,i,n)}D(t,"inactive")}function D(t,e,i){t.ga&&t.P[e]&&(i?t.P[e](i.getName(),k(i)):t.P[e]())}function A(){this.w={}}function I(t,e){this.d=t,this.G=e,this.m=this.d.createElement("span",{"aria-hidden":"true"},this.G)}function x(t){a(t.d,"body",t.m)}function R(t){var e;e=[];for(var i=t.M.split(/,\s*/),n=0;n<i.length;n++){var s=i[n].replace(/['"]/g,"");-1==s.indexOf(" ")?e.push(s):e.push("'"+s+"'")}return e=e.join(","),i="normal","o"===t.N?i="oblique":"i"===t.N&&(i="italic"),"display:block;position:absolute;top:-999px;left:-999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;white-space:nowrap;font-family:"+e+";"+("font-style:"+i+";font-weight:"+(t.Y+"00")+";")}function M(t,e,i,n,s,o,a,r){this.Z=t,this.ja=e,this.d=i,this.s=n,this.G=r||"BESbswy",this.k=s,this.I={},this.W=o||3e3,this.ba=a||null,this.F=this.D=null,t=new I(this.d,this.G),x(t);for(var l in Z)Z.hasOwnProperty(l)&&(e=new L(Z[l],k(this.s)),e=R(e),t.m.style.cssText=e,this.I[Z[l]]=t.m.offsetWidth);t.remove()}function O(t,e,i){for(var n in Z)if(Z.hasOwnProperty(n)&&e===t.I[Z[n]]&&i===t.I[Z[n]])return!0;return!1}function P(t){var e=t.D.m.offsetWidth,i=t.F.m.offsetWidth;e===t.I.serif&&i===t.I["sans-serif"]||t.k.fa&&O(t,e,i)?X()-t.na>=t.W?t.k.fa&&O(t,e,i)&&(null===t.ba||t.ba.hasOwnProperty(t.s.getName()))?$(t,t.Z):$(t,t.ja):N(t):$(t,t.Z)}function N(t){setTimeout(s(function(){P(this)},t),25)}function $(t,e){t.D.remove(),t.F.remove(),e(t.s)}function U(t,e,i,n){this.d=e,this.u=i,this.R=0,this.da=this.aa=!1,this.W=n,this.k=t.k}function F(t,e,i,n,o){if(i=i||{},0===e.length&&o)_(t.u);else for(t.R+=e.length,o&&(t.aa=o),o=0;o<e.length;o++){var a=e[o],r=i[a.getName()],d=t.u,c=a;d.B&&l(d.p,[d.h.e(d.j,c.getName(),k(c).toString(),"loading")]),D(d,"fontloading",c),d=null,d=new M(s(t.ha,t),s(t.ia,t),t.d,a,t.k,t.W,n,r),d.start()}}function B(t){0==--t.R&&t.aa&&(t.da?(t=t.u,t.B&&l(t.p,[t.h.e(t.j,"active")],[t.h.e(t.j,"loading"),t.h.e(t.j,"inactive")]),D(t,"active")):_(t.u))}function H(t){this.J=t,this.v=new A,this.oa=new v(t.navigator.userAgent),this.a=this.oa.parse(),this.T=this.U=0,this.Q=this.S=!0}function j(t,e,i,n,s){var o=0==--t.U;(t.Q||t.S)&&setTimeout(function(){F(e,i,n||null,s||null,o)},0)}function V(t,e,i){this.O=t?t:e+tt,this.q=[],this.V=[],this.ea=i||""}function z(t){this.q=t,this.ca=[],this.L={}}function G(t,e){this.a=new v(navigator.userAgent).parse(),this.d=t,this.f=e}function W(t,e){this.d=t,this.f=e,this.o=[]}function K(t,e){this.d=t,this.f=e,this.o=[]}function Y(t,e){this.d=t,this.f=e,this.o=[]}function q(t,e){this.d=t,this.f=e}var X=Date.now||function(){return+new Date};o.prototype.createElement=function(t,e,i){if(t=this.C.createElement(t),e)for(var n in e)e.hasOwnProperty(n)&&("style"==n?t.style.cssText=e[n]:t.setAttribute(n,e[n]));return i&&t.appendChild(this.C.createTextNode(i)),t};var J=/^([0-9]+)(?:[\._-]([0-9]+))?(?:[\._-]([0-9]+))?(?:[\._+-]?(.*))?$/;m.prototype.compare=function(t){return this.c>t.c||this.c===t.c&&this.g>t.g||this.c===t.c&&this.g===t.g&&this.A>t.A?1:this.c<t.c||this.c===t.c&&this.g<t.g||this.c===t.c&&this.g===t.g&&this.A<t.A?-1:0},m.prototype.toString=function(){return[this.c,this.g||"",this.A||"",this.e||""].join("")},g.prototype.getName=function(){return this.M};var Q=new g("Unknown",0,0,0,0,0,0,new p(!1,!1));v.prototype.parse=function(){var t;if(-1!=this.a.indexOf("MSIE")||-1!=this.a.indexOf("Trident/")){t=b(this);var e=f(S(this)),i=null,n=E(this.a,/Trident\/([\d\w\.]+)/,1),i=f(-1!=this.a.indexOf("MSIE")?E(this.a,/MSIE ([\d\w\.]+)/,1):E(this.a,/rv:([\d\w\.]+)/,1));""!=n&&f(n),t=new g("MSIE",0,0,0,0,0,0,new p("Windows"==t&&6<=i.c||"Windows Phone"==t&&8<=e.c,!1))}else if(-1!=this.a.indexOf("Opera"))t:if(t=f(E(this.a,/Presto\/([\d\w\.]+)/,1)),f(S(this)),null!==t.c||f(E(this.a,/rv:([^\)]+)/,1)),-1!=this.a.indexOf("Opera Mini/"))t=f(E(this.a,/Opera Mini\/([\d\.]+)/,1)),t=new g("OperaMini",0,0,0,b(this),0,0,new p(!1,!1));else{if(-1!=this.a.indexOf("Version/")&&(t=f(E(this.a,/Version\/([\d\.]+)/,1)),null!==t.c)){t=new g("Opera",0,0,0,b(this),0,0,new p(10<=t.c,!1));break t}t=f(E(this.a,/Opera[\/ ]([\d\.]+)/,1)),t=null!==t.c?new g("Opera",0,0,0,b(this),0,0,new p(10<=t.c,!1)):new g("Opera",0,0,0,b(this),0,0,new p(!1,!1))}else/OPR\/[\d.]+/.test(this.a)?t=y(this):/AppleWeb(K|k)it/.test(this.a)?t=y(this):-1!=this.a.indexOf("Gecko")?(t="Unknown",e=new m,f(S(this)),e=!1,-1!=this.a.indexOf("Firefox")?(t="Firefox",e=f(E(this.a,/Firefox\/([\d\w\.]+)/,1)),e=3<=e.c&&5<=e.g):-1!=this.a.indexOf("Mozilla")&&(t="Mozilla"),i=f(E(this.a,/rv:([^\)]+)/,1)),e||(e=1<i.c||1==i.c&&9<i.g||1==i.c&&9==i.g&&2<=i.A),t=new g(t,0,0,0,b(this),0,0,new p(e,!1))):t=Q;return t},T.prototype.e=function(){for(var t=[],e=0;e<arguments.length;e++)t.push(arguments[e].replace(/[\W_]+/g,"").toLowerCase());return t.join(this.la)},L.prototype.getName=function(){return this.M},I.prototype.remove=function(){var t=this.m;t.parentNode&&t.parentNode.removeChild(t)};var Z={ra:"serif",qa:"sans-serif",pa:"monospace"};M.prototype.start=function(){this.D=new I(this.d,this.G),x(this.D),this.F=new I(this.d,this.G),x(this.F),this.na=X();var t=new L(this.s.getName()+",serif",k(this.s)),t=R(t);this.D.m.style.cssText=t,t=new L(this.s.getName()+",sans-serif",k(this.s)),t=R(t),this.F.m.style.cssText=t,P(this)},U.prototype.ha=function(t){var e=this.u;e.B&&l(e.p,[e.h.e(e.j,t.getName(),k(t).toString(),"active")],[e.h.e(e.j,t.getName(),k(t).toString(),"loading"),e.h.e(e.j,t.getName(),k(t).toString(),"inactive")]),D(e,"fontactive",t),this.da=!0,B(this)},U.prototype.ia=function(t){var e=this.u;if(e.B){var i=d(e.p,e.h.e(e.j,t.getName(),k(t).toString(),"active")),n=[],s=[e.h.e(e.j,t.getName(),k(t).toString(),"loading")];i||n.push(e.h.e(e.j,t.getName(),k(t).toString(),"inactive")),l(e.p,n,s)}D(e,"fontinactive",t),B(this)},H.prototype.load=function(t){this.d=new o(this.J,t.context||this.J),this.S=!1!==t.events,this.Q=!1!==t.classes;var e=new C(this.d,t),i=[],n=t.timeout;e.B&&l(e.p,[e.h.e(e.j,"loading")]),D(e,"loading");var a,i=this.v,r=this.d,d=[];for(a in t)if(t.hasOwnProperty(a)){var c=i.w[a];c&&d.push(c(t[a],r))}for(i=d,this.T=this.U=i.length,t=new U(this.a,this.d,e,n),n=0,a=i.length;n<a;n++)r=i[n],r.K(this.a,s(this.ka,this,r,e,t))},H.prototype.ka=function(t,e,i,n){var s=this;n?t.load(function(t,e,n){j(s,i,t,e,n)}):(t=0==--this.U,this.T--,t&&0==this.T?_(e):(this.Q||this.S)&&F(i,[],{},null,t))};var tt="//fonts.googleapis.com/css";V.prototype.e=function(){if(0==this.q.length)throw Error("No fonts to load!");if(-1!=this.O.indexOf("kit="))return this.O;for(var t=this.q.length,e=[],i=0;i<t;i++)e.push(this.q[i].replace(/ /g,"+"));return t=this.O+"?family="+e.join("%7C"),0<this.V.length&&(t+="&subset="+this.V.join(",")),0<this.ea.length&&(t+="&text="+encodeURIComponent(this.ea)),t};var et={latin:"BESbswy",cyrillic:"&#1081;&#1103;&#1046;",greek:"&#945;&#946;&#931;",khmer:"&#x1780;&#x1781;&#x1782;",Hanuman:"&#x1780;&#x1781;&#x1782;"},it={thin:"1",extralight:"2","extra-light":"2",ultralight:"2","ultra-light":"2",light:"3",regular:"4",book:"4",medium:"5","semi-bold":"6",semibold:"6","demi-bold":"6",demibold:"6",bold:"7","extra-bold":"8",extrabold:"8","ultra-bold":"8",ultrabold:"8",black:"9",heavy:"9",l:"3",r:"4",b:"7"},nt={i:"i",italic:"i",n:"n",normal:"n"},st=/^(thin|(?:(?:extra|ultra)-?)?light|regular|book|medium|(?:(?:semi|demi|extra|ultra)-?)?bold|black|heavy|l|r|b|[1-9]00)?(n|i|normal|italic)?$/;z.prototype.parse=function(){for(var t=this.q.length,e=0;e<t;e++){var i=this.q[e].split(":"),n=i[0].replace(/\+/g," "),s=["n4"];if(2<=i.length){var o,a=i[1];if(o=[],a)for(var a=a.split(","),r=a.length,l=0;l<r;l++){var d;if(d=a[l],d.match(/^[\w-]+$/)){d=st.exec(d.toLowerCase());var c=void 0;if(null==d)c="";else{if(c=void 0,c=d[1],null==c||""==c)c="4";else var h=it[c],c=h?h:isNaN(c)?"4":c.substr(0,1);d=d[2],c=[null==d||""==d?"n":nt[d],c].join("")}d=c}else d="";d&&o.push(d)}0<o.length&&(s=o),3==i.length&&(i=i[2],o=[],i=i?i.split(","):o,0<i.length&&(i=et[i[0]])&&(this.L[n]=i))}for(this.L[n]||(i=et[n])&&(this.L[n]=i),i=0;i<s.length;i+=1)this.ca.push(new L(n,s[i]))}};var ot={Arimo:!0,Cousine:!0,Tinos:!0};G.prototype.K=function(t,e){e(t.k.X)},G.prototype.load=function(t){var e=this.d;"MSIE"==this.a.getName()&&1!=this.f.blocking?r(e,s(this.$,this,t)):this.$(t)},G.prototype.$=function(t){for(var e=this.d,i=new V(this.f.api,c(e),this.f.text),n=this.f.families,s=n.length,o=0;o<s;o++){var a=n[o].split(":");3==a.length&&i.V.push(a.pop());var r="";2==a.length&&""!=a[1]&&(r=":"),i.q.push(a.join(r))}n=new z(n),n.parse(),h(e,i.e()),t(n.ca,n.L,ot)},W.prototype.H=function(t){var e=this.d;return c(this.d)+(this.f.api||"//f.fontdeck.com/s/css/js/")+(e.t.location.hostname||e.J.location.hostname)+"/"+t+".js"},W.prototype.K=function(t,e){var i=this.f.id,n=this.d.t,s=this;i?(n.__webfontfontdeckmodule__||(n.__webfontfontdeckmodule__={}),n.__webfontfontdeckmodule__[i]=function(t,i){for(var n=0,o=i.fonts.length;n<o;++n){var a=i.fonts[n];s.o.push(new L(a.name,w("font-weight:"+a.weight+";font-style:"+a.style)))}e(t)},u(this.d,this.H(i),function(t){t&&e(!1)})):e(!1)},W.prototype.load=function(t){t(this.o)},K.prototype.H=function(t){var e=c(this.d);return(this.f.api||e+"//use.typekit.net")+"/"+t+".js"},K.prototype.K=function(t,e){var i=this.f.id,n=this.d.t,s=this;i?u(this.d,this.H(i),function(t){if(t)e(!1);else{if(n.Typekit&&n.Typekit.config&&n.Typekit.config.fn){t=n.Typekit.config.fn;for(var i=0;i<t.length;i+=2)for(var o=t[i],a=t[i+1],r=0;r<a.length;r++)s.o.push(new L(o,a[r]));try{n.Typekit.load({events:!1,classes:!1})}catch(t){}}e(!0)}},2e3):e(!1)},K.prototype.load=function(t){t(this.o)},Y.prototype.K=function(t,e){var i=this,n=i.f.projectId,s=i.f.version;if(n){var o=i.d.t;u(this.d,i.H(n,s),function(s){if(s)e(!1);else{if(o["__mti_fntLst"+n]&&(s=o["__mti_fntLst"+n]()))for(var a=0;a<s.length;a++)i.o.push(new L(s[a].fontfamily));e(t.k.X)}}).id="__MonotypeAPIScript__"+n}else e(!1)},Y.prototype.H=function(t,e){var i=c(this.d),n=(this.f.api||"fast.fonts.net/jsapi").replace(/^.*http(s?):(\/\/)?/,"");return i+"//"+n+"/"+t+".js"+(e?"?v="+e:"")},Y.prototype.load=function(t){t(this.o)},q.prototype.load=function(t){var e,i,n=this.f.urls||[],s=this.f.families||[],o=this.f.testStrings||{};for(e=0,i=n.length;e<i;e++)h(this.d,n[e]);for(n=[],e=0,i=s.length;e<i;e++){var a=s[e].split(":");if(a[1])for(var r=a[1].split(","),l=0;l<r.length;l+=1)n.push(new L(a[0],r[l]));else n.push(new L(a[0]))}t(n,o)},q.prototype.K=function(t,e){return e(t.k.X)};var at=new H(this);at.v.w.custom=function(t,e){return new q(e,t)},at.v.w.fontdeck=function(t,e){return new W(e,t)},at.v.w.monotype=function(t,e){return new Y(e,t)},at.v.w.typekit=function(t,e){return new K(e,t)},at.v.w.google=function(t,e){return new G(e,t)},this.WebFont||(this.WebFont={},this.WebFont.load=s(at.load,at),this.WebFontConfig&&at.load(this.WebFontConfig))}(this,document),function(t,e,i){e[t]=e[t]||i(),"undefined"!=typeof module&&module.exports?module.exports=e[t]:"function"==typeof define&&define.amd&&define(function(){return e[t]})}("Promise","undefined"!=typeof global?global:this,function(){"use strict";function t(t,e){u.add(t,e),h||(h=m(u.drain))}function e(t){var e,i=typeof t;return null==t||"object"!=i&&"function"!=i||(e=t.then),"function"==typeof e&&e}function i(){for(var t=0;t<this.chain.length;t++)n(this,1===this.state?this.chain[t].success:this.chain[t].failure,this.chain[t]);this.chain.length=0}function n(t,i,n){var s,o;try{i===!1?n.reject(t.msg):(s=i===!0?t.msg:i.call(void 0,t.msg),s===n.promise?n.reject(TypeError("Promise-chain cycle")):(o=e(s))?o.call(s,n.resolve,n.reject):n.resolve(s))}catch(t){n.reject(t)}}function s(n){var a,l=this;if(!l.triggered){l.triggered=!0,l.def&&(l=l.def);try{(a=e(n))?t(function(){var t=new r(l);try{a.call(n,function(){s.apply(t,arguments)},function(){o.apply(t,arguments)})}catch(e){o.call(t,e)}}):(l.msg=n,l.state=1,l.chain.length>0&&t(i,l))}catch(t){o.call(new r(l),t)}}}function o(e){var n=this;n.triggered||(n.triggered=!0,n.def&&(n=n.def),n.msg=e,n.state=2,n.chain.length>0&&t(i,n))}function a(t,e,i,n){for(var s=0;s<e.length;s++)!function(s){
t.resolve(e[s]).then(function(t){i(s,t)},n)}(s)}function r(t){this.def=t,this.triggered=!1}function l(t){this.promise=t,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function d(e){if("function"!=typeof e)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var n=new l(this);this.then=function(e,s){var o={success:"function"!=typeof e||e,failure:"function"==typeof s&&s};return o.promise=new this.constructor(function(t,e){if("function"!=typeof t||"function"!=typeof e)throw TypeError("Not a function");o.resolve=t,o.reject=e}),n.chain.push(o),0!==n.state&&t(i,n),o.promise},this["catch"]=function(t){return this.then(void 0,t)};try{e.call(void 0,function(t){s.call(n,t)},function(t){o.call(n,t)})}catch(t){o.call(n,t)}}var c,h,u,p=Object.prototype.toString,m="undefined"!=typeof setImmediate?function(t){return setImmediate(t)}:setTimeout;try{Object.defineProperty({},"x",{}),c=function(t,e,i,n){return Object.defineProperty(t,e,{value:i,writable:!0,configurable:n!==!1})}}catch(t){c=function(t,e,i){return t[e]=i,t}}u=function(){function t(t,e){this.fn=t,this.self=e,this.next=void 0}var e,i,n;return{add:function(s,o){n=new t(s,o),i?i.next=n:e=n,i=n,n=void 0},drain:function(){var t=e;for(e=i=h=void 0;t;)t.fn.call(t.self),t=t.next}}}();var f=c({},"constructor",d,!1);return d.prototype=f,c(f,"__NPO__",0,!1),c(d,"resolve",function(t){var e=this;return t&&"object"==typeof t&&1===t.__NPO__?t:new e(function(e,i){if("function"!=typeof e||"function"!=typeof i)throw TypeError("Not a function");e(t)})}),c(d,"reject",function(t){return new this(function(e,i){if("function"!=typeof e||"function"!=typeof i)throw TypeError("Not a function");i(t)})}),c(d,"all",function(t){var e=this;return"[object Array]"!=p.call(t)?e.reject(TypeError("Not an array")):0===t.length?e.resolve([]):new e(function(i,n){if("function"!=typeof i||"function"!=typeof n)throw TypeError("Not a function");var s=t.length,o=Array(s),r=0;a(e,t,function(t,e){o[t]=e,++r===s&&i(o)},n)})}),c(d,"race",function(t){var e=this;return"[object Array]"!=p.call(t)?e.reject(TypeError("Not an array")):new e(function(i,n){if("function"!=typeof i||"function"!=typeof n)throw TypeError("Not a function");a(e,t,function(t,e){i(e)},n)})}),d}),!function(t){if(!t.hasInitialised){var e={escapeRegExp:function(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},hasClass:function(t,e){var i=" ";return 1===t.nodeType&&(i+t.className+i).replace(/[\n\t]/g,i).indexOf(i+e+i)>=0},addClass:function(t,e){t.className+=" "+e},removeClass:function(t,e){var i=new RegExp("\\b"+this.escapeRegExp(e)+"\\b");t.className=t.className.replace(i,"")},interpolateString:function(t,e){var i=/{{([a-z][a-z0-9\-_]*)}}/gi;return t.replace(i,function(){return e(arguments[1])||""})},getCookie:function(t){var e="; "+document.cookie,i=e.split("; "+t+"=");return 2!=i.length?void 0:i.pop().split(";").shift()},setCookie:function(t,e,i,n,s){var o=new Date;o.setDate(o.getDate()+(i||365));var a=[t+"="+e,"expires="+o.toUTCString(),"path="+(s||"/")];n&&a.push("domain="+n),document.cookie=a.join(";")},deepExtend:function(t,e){for(var i in e)e.hasOwnProperty(i)&&(i in t&&this.isPlainObject(t[i])&&this.isPlainObject(e[i])?this.deepExtend(t[i],e[i]):t[i]=e[i]);return t},throttle:function(t,e){var i=!1;return function(){i||(t.apply(this,arguments),i=!0,setTimeout(function(){i=!1},e))}},hash:function(t){var e,i,n,s=0;if(0===t.length)return s;for(e=0,n=t.length;e<n;++e)i=t.charCodeAt(e),s=(s<<5)-s+i,s|=0;return s},normaliseHex:function(t){return"#"==t[0]&&(t=t.substr(1)),3==t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),t},getContrast:function(t){t=this.normaliseHex(t);var e=parseInt(t.substr(0,2),16),i=parseInt(t.substr(2,2),16),n=parseInt(t.substr(4,2),16),s=(299*e+587*i+114*n)/1e3;return s>=128?"#000":"#fff"},getLuminance:function(t){var e=parseInt(this.normaliseHex(t),16),i=38,n=(e>>16)+i,s=(e>>8&255)+i,o=(255&e)+i,a=(16777216+65536*(n<255?n<1?0:n:255)+256*(s<255?s<1?0:s:255)+(o<255?o<1?0:o:255)).toString(16).slice(1);return"#"+a},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},isPlainObject:function(t){return"object"==typeof t&&null!==t&&t.constructor==Object}};t.status={deny:"deny",allow:"allow",dismiss:"dismiss"},t.transitionEnd=function(){var t=document.createElement("div"),e={t:"transitionend",OT:"oTransitionEnd",msT:"MSTransitionEnd",MozT:"transitionend",WebkitT:"webkitTransitionEnd"};for(var i in e)if(e.hasOwnProperty(i)&&"undefined"!=typeof t.style[i+"ransition"])return e[i];return""}(),t.hasTransition=!!t.transitionEnd;var i=Object.keys(t.status).map(e.escapeRegExp);t.customStyles={},t.Popup=function(){function n(){this.initialise.apply(this,arguments)}function s(t){this.openingTimeout=null,e.removeClass(t,"cc-invisible")}function o(e){e.style.display="none",e.removeEventListener(t.transitionEnd,this.afterTransition),this.afterTransition=null}function a(){var e=this.options.onInitialise.bind(this);if(!window.navigator.cookieEnabled)return e(t.status.deny),!0;if(window.CookiesOK||window.navigator.CookiesOK)return e(t.status.allow),!0;var i=Object.keys(t.status),n=this.getStatus(),s=i.indexOf(n)>=0;return s&&e(n),s}function r(){var t=this.options.position.split("-"),e=[];return t.forEach(function(t){e.push("cc-"+t)}),e}function l(){var t=this.options,i="top"==t.position||"bottom"==t.position?"banner":"floating";e.isMobile()&&(i="floating");var n=["cc-"+i,"cc-type-"+t.type,"cc-theme-"+t.theme];return t["static"]&&n.push("cc-static"),n.push.apply(n,r.call(this)),u.call(this,this.options.palette),this.customStyleSelector&&n.push(this.customStyleSelector),n}function d(){var t={},i=this.options;i.showLink||(i.elements.link="",i.elements.messagelink=i.elements.message),Object.keys(i.elements).forEach(function(n){t[n]=e.interpolateString(i.elements[n],function(t){var e=i.content[t];return t&&"string"==typeof e&&e.length?e:""})});var n=i.compliance[i.type];n||(n=i.compliance.info),t.compliance=e.interpolateString(n,function(e){return t[e]});var s=i.layouts[i.layout];return s||(s=i.layouts.basic),e.interpolateString(s,function(e){return t[e]})}function c(i){var n=this.options,s=document.createElement("div"),o=n.container&&1===n.container.nodeType?n.container:document.body;s.innerHTML=i;var a=s.children[0];return a.style.display="none",e.hasClass(a,"cc-window")&&t.hasTransition&&e.addClass(a,"cc-invisible"),this.onButtonClick=h.bind(this),a.addEventListener("click",this.onButtonClick),n.autoAttach&&(o.firstChild?o.insertBefore(a,o.firstChild):o.appendChild(a)),a}function h(n){var s=n.target;if(e.hasClass(s,"cc-btn")){var o=s.className.match(new RegExp("\\bcc-("+i.join("|")+")\\b")),a=o&&o[1]||!1;a&&(this.setStatus(a),this.close(!0))}e.hasClass(s,"cc-close")&&(this.setStatus(t.status.dismiss),this.close(!0)),e.hasClass(s,"cc-revoke")&&this.revokeChoice()}function u(t){var i=e.hash(JSON.stringify(t)),n="cc-color-override-"+i,s=e.isPlainObject(t);return this.customStyleSelector=s?n:null,s&&p(i,t,"."+n),s}function p(i,n,s){if(t.customStyles[i])return void++t.customStyles[i].references;var o={},a=n.popup,r=n.button,l=n.highlight;a&&(a.text=a.text?a.text:e.getContrast(a.background),a.link=a.link?a.link:a.text,o[s+".cc-window"]=["color: "+a.text,"background-color: "+a.background],o[s+".cc-revoke"]=["color: "+a.text,"background-color: "+a.background],o[s+" .cc-link,"+s+" .cc-link:active,"+s+" .cc-link:visited"]=["color: "+a.link],r&&(r.text=r.text?r.text:e.getContrast(r.background),r.border=r.border?r.border:"transparent",o[s+" .cc-btn"]=["color: "+r.text,"border-color: "+r.border,"background-color: "+r.background],"transparent"!=r.background&&(o[s+" .cc-btn:hover, "+s+" .cc-btn:focus"]=["background-color: "+m(r.background)]),l?(l.text=l.text?l.text:e.getContrast(l.background),l.border=l.border?l.border:"transparent",o[s+" .cc-highlight .cc-btn:first-child"]=["color: "+l.text,"border-color: "+l.border,"background-color: "+l.background]):o[s+" .cc-highlight .cc-btn:first-child"]=["color: "+a.text]));var d=document.createElement("style");document.head.appendChild(d),t.customStyles[i]={references:1,element:d.sheet};var c=-1;for(var h in o)o.hasOwnProperty(h)&&d.sheet.insertRule(h+"{"+o[h].join(";")+"}",++c)}function m(t){return t=e.normaliseHex(t),"000000"==t?"#222":e.getLuminance(t)}function f(i){if(e.isPlainObject(i)){var n=e.hash(JSON.stringify(i)),s=t.customStyles[n];if(s&&!--s.references){var o=s.element.ownerNode;o&&o.parentNode&&o.parentNode.removeChild(o),t.customStyles[n]=null}}}function g(t,e){for(var i=0,n=t.length;i<n;++i){var s=t[i];if(s instanceof RegExp&&s.test(e)||"string"==typeof s&&s.length&&s===e)return!0}return!1}function v(){var e=this.setStatus.bind(this),i=this.options.dismissOnTimeout;"number"==typeof i&&i>=0&&(this.dismissTimeout=window.setTimeout(function(){e(t.status.dismiss)},Math.floor(i)));var n=this.options.dismissOnScroll;if("number"==typeof n&&n>=0){var s=function(){window.pageYOffset>Math.floor(n)&&(e(t.status.dismiss),window.removeEventListener("scroll",s),this.onWindowScroll=null)};this.onWindowScroll=s,window.addEventListener("scroll",s)}}function b(){if("info"!=this.options.type&&(this.options.revokable=!0),e.isMobile()&&(this.options.animateRevokable=!1),this.options.revokable){var t=r.call(this);this.options.animateRevokable&&t.push("cc-animate"),this.customStyleSelector&&t.push(this.customStyleSelector);var i=this.options.revokeBtn.replace("{{classes}}",t.join(" "));this.revokeBtn=c.call(this,i);var n=this.revokeBtn;if(this.options.animateRevokable){var s=e.throttle(function(t){var i=!1,s=20,o=window.innerHeight-20;e.hasClass(n,"cc-top")&&t.clientY<s&&(i=!0),e.hasClass(n,"cc-bottom")&&t.clientY>o&&(i=!0),i?e.hasClass(n,"cc-active")||e.addClass(n,"cc-active"):e.hasClass(n,"cc-active")&&e.removeClass(n,"cc-active")},200);this.onMouseMove=s,window.addEventListener("mousemove",s)}}}var S={enabled:!0,container:null,cookie:{name:"cookieconsent_status",path:"/",domain:"",expiryDays:365},onPopupOpen:function(){},onPopupClose:function(){},onInitialise:function(){},onStatusChange:function(){},onRevokeChoice:function(){},content:{header:"Cookies used on the website!",message:"This website uses cookies to ensure you get the best experience on our website.",dismiss:"Got it!",allow:"Allow cookies",deny:"Decline",link:"Learn more",href:"http://cookiesandyou.com",close:"&#x274c;"},elements:{header:'<span class="cc-header">{{header}}</span>&nbsp;',message:'<span id="cookieconsent:desc" class="cc-message">{{message}}</span>',messagelink:'<span id="cookieconsent:desc" class="cc-message">{{message}} <a aria-label="learn more about cookies" role=button tabindex="0" class="cc-link" href="{{href}}" rel="noopener noreferrer nofollow" target="_blank">{{link}}</a></span>',dismiss:'<a aria-label="dismiss cookie message" role=button tabindex="0" class="cc-btn cc-dismiss">{{dismiss}}</a>',allow:'<a aria-label="allow cookies" role=button tabindex="0"  class="cc-btn cc-allow">{{allow}}</a>',deny:'<a aria-label="deny cookies" role=button tabindex="0" class="cc-btn cc-deny">{{deny}}</a>',link:'<a aria-label="learn more about cookies" role=button tabindex="0" class="cc-link" href="{{href}}" target="_blank">{{link}}</a>',close:'<span aria-label="dismiss cookie message" role=button tabindex="0" class="cc-close">{{close}}</span>'},window:'<div role="dialog" aria-live="polite" aria-label="cookieconsent" aria-describedby="cookieconsent:desc" class="cc-window {{classes}}"><!--googleoff: all-->{{children}}<!--googleon: all--></div>',revokeBtn:'<div class="cc-revoke {{classes}}">Cookie Policy</div>',compliance:{info:'<div class="cc-compliance">{{dismiss}}</div>',"opt-in":'<div class="cc-compliance cc-highlight">{{dismiss}}{{allow}}</div>',"opt-out":'<div class="cc-compliance cc-highlight">{{deny}}{{dismiss}}</div>'},type:"info",layouts:{basic:"{{messagelink}}{{compliance}}","basic-close":"{{messagelink}}{{compliance}}{{close}}","basic-header":"{{header}}{{message}}{{link}}{{compliance}}"},layout:"basic",position:"bottom",theme:"block","static":!1,palette:null,revokable:!1,animateRevokable:!0,showLink:!0,dismissOnScroll:!1,dismissOnTimeout:!1,autoOpen:!0,autoAttach:!0,whitelistPage:[],blacklistPage:[],overrideHTML:null};return n.prototype.initialise=function(t){this.options&&this.destroy(),e.deepExtend(this.options={},S),e.isPlainObject(t)&&e.deepExtend(this.options,t),a.call(this)&&(this.options.enabled=!1),g(this.options.blacklistPage,location.pathname)&&(this.options.enabled=!1),g(this.options.whitelistPage,location.pathname)&&(this.options.enabled=!0);var i=this.options.window.replace("{{classes}}",l.call(this).join(" ")).replace("{{children}}",d.call(this)),n=this.options.overrideHTML;if("string"==typeof n&&n.length&&(i=n),this.options["static"]){var s=c.call(this,'<div class="cc-grower">'+i+"</div>");s.style.display="",this.element=s.firstChild,this.element.style.display="none",e.addClass(this.element,"cc-invisible")}else this.element=c.call(this,i);v.call(this),b.call(this),this.options.autoOpen&&this.autoOpen()},n.prototype.destroy=function(){this.onButtonClick&&this.element&&(this.element.removeEventListener("click",this.onButtonClick),this.onButtonClick=null),this.dismissTimeout&&(clearTimeout(this.dismissTimeout),this.dismissTimeout=null),this.onWindowScroll&&(window.removeEventListener("scroll",this.onWindowScroll),this.onWindowScroll=null),this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.revokeBtn&&this.revokeBtn.parentNode&&this.revokeBtn.parentNode.removeChild(this.revokeBtn),this.revokeBtn=null,f(this.options.palette),this.options=null},n.prototype.open=function(){if(this.element)return this.isOpen()||(t.hasTransition?this.fadeIn():this.element.style.display="",this.options.revokable&&this.toggleRevokeButton(),this.options.onPopupOpen.call(this)),this},n.prototype.close=function(e){if(this.element)return this.isOpen()&&(t.hasTransition?this.fadeOut():this.element.style.display="none",e&&this.options.revokable&&this.toggleRevokeButton(!0),this.options.onPopupClose.call(this)),this},n.prototype.fadeIn=function(){var i=this.element;if(t.hasTransition&&i&&(this.afterTransition&&o.call(this,i),e.hasClass(i,"cc-invisible"))){if(i.style.display="",this.options["static"]){var n=this.element.clientHeight;this.element.parentNode.style.maxHeight=n+"px"}var a=20;this.openingTimeout=setTimeout(s.bind(this,i),a)}},n.prototype.fadeOut=function(){var i=this.element;t.hasTransition&&i&&(this.openingTimeout&&(clearTimeout(this.openingTimeout),s.bind(this,i)),e.hasClass(i,"cc-invisible")||(this.options["static"]&&(this.element.parentNode.style.maxHeight=""),this.afterTransition=o.bind(this,i),i.addEventListener(t.transitionEnd,this.afterTransition),e.addClass(i,"cc-invisible")))},n.prototype.isOpen=function(){return this.element&&""==this.element.style.display&&(!t.hasTransition||!e.hasClass(this.element,"cc-invisible"))},n.prototype.toggleRevokeButton=function(t){this.revokeBtn&&(this.revokeBtn.style.display=t?"":"none")},n.prototype.revokeChoice=function(t){this.options.enabled=!0,this.clearStatus(),this.options.onRevokeChoice.call(this),t||this.autoOpen()},n.prototype.hasAnswered=function(){return Object.keys(t.status).indexOf(this.getStatus())>=0},n.prototype.hasConsented=function(){var e=this.getStatus();return e==t.status.allow||e==t.status.dismiss},n.prototype.autoOpen=function(){!this.hasAnswered()&&this.options.enabled&&this.open()},n.prototype.setStatus=function(i){var n=this.options.cookie,s=e.getCookie(n.name),o=Object.keys(t.status).indexOf(s)>=0;Object.keys(t.status).indexOf(i)>=0?(e.setCookie(n.name,i,n.expiryDays,n.domain,n.path),this.options.onStatusChange.call(this,i,o)):this.clearStatus()},n.prototype.getStatus=function(){return e.getCookie(this.options.cookie.name)},n.prototype.clearStatus=function(){var t=this.options.cookie;e.setCookie(t.name,"",-1,t.domain,t.path)},n}(),t.Location=function(){function t(t){e.deepExtend(this.options={},o),e.isPlainObject(t)&&e.deepExtend(this.options,t),this.currentServiceIndex=-1}function i(t,e,i){var n,s=document.createElement("script");s.type="text/"+(t.type||"javascript"),s.src=t.src||t,s.async=!1,s.onreadystatechange=s.onload=function(){var t=s.readyState;clearTimeout(n),e.done||t&&!/loaded|complete/.test(t)||(e.done=!0,e(),s.onreadystatechange=s.onload=null)},document.body.appendChild(s),n=setTimeout(function(){e.done=!0,e(),s.onreadystatechange=s.onload=null},i)}function n(t,e,i,n,s){var o=new(window.XMLHttpRequest||window.ActiveXObject)("MSXML2.XMLHTTP.3.0");if(o.open(n?"POST":"GET",t,1),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),Array.isArray(s))for(var a=0,r=s.length;a<r;++a){var l=s[a].split(":",2);o.setRequestHeader(l[0].replace(/^\s+|\s+$/g,""),l[1].replace(/^\s+|\s+$/g,""))}"function"==typeof e&&(o.onreadystatechange=function(){o.readyState>3&&e(o)}),o.send(n)}function s(t){return new Error("Error ["+(t.code||"UNKNOWN")+"]: "+t.error)}var o={timeout:5e3,services:["freegeoip","ipinfo","maxmind"],serviceDefinitions:{freegeoip:function(){return{url:"//freegeoip.net/json/?callback={callback}",isScript:!0,callback:function(t,e){try{var i=JSON.parse(e);return i.error?s(i):{code:i.country_code}}catch(t){return s({error:"Invalid response ("+t+")"})}}}},ipinfo:function(){return{url:"//ipinfo.io",headers:["Accept: application/json"],callback:function(t,e){try{var i=JSON.parse(e);return i.error?s(i):{code:i.country}}catch(t){return s({error:"Invalid response ("+t+")"})}}}},ipinfodb:function(){return{url:"//api.ipinfodb.com/v3/ip-country/?key={api_key}&format=json&callback={callback}",isScript:!0,callback:function(t,e){try{var i=JSON.parse(e);return"ERROR"==i.statusCode?s({error:i.statusMessage}):{code:i.countryCode}}catch(t){return s({error:"Invalid response ("+t+")"})}}}},maxmind:function(){return{url:"//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js",isScript:!0,callback:function(t){return window.geoip2?void geoip2.country(function(e){try{t({code:e.country.iso_code})}catch(e){t(s(e))}},function(e){t(s(e))}):void t(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope"))}}}}};return t.prototype.getNextService=function(){var t;do t=this.getServiceByIdx(++this.currentServiceIndex);while(this.currentServiceIndex<this.options.services.length&&!t);return t},t.prototype.getServiceByIdx=function(t){var i=this.options.services[t];if("function"==typeof i){var n=i();return n.name&&e.deepExtend(n,this.options.serviceDefinitions[n.name](n)),n}return"string"==typeof i?this.options.serviceDefinitions[i]():e.isPlainObject(i)?this.options.serviceDefinitions[i.name](i):null},t.prototype.locate=function(t,e){var i=this.getNextService();return i?(this.callbackComplete=t,this.callbackError=e,void this.runService(i,this.runNextServiceOnError.bind(this))):void e(new Error("No services to run"))},t.prototype.setupUrl=function(t){var e=this.getCurrentServiceOpts();return t.url.replace(/\{(.*?)\}/g,function(i,n){if("callback"===n){var s="callback"+Date.now();return window[s]=function(e){t.__JSONP_DATA=JSON.stringify(e)},s}if(n in e.interpolateUrl)return e.interpolateUrl[n]})},t.prototype.runService=function(t,e){var s=this;if(t&&t.url&&t.callback){var o=t.isScript?i:n,a=this.setupUrl(t);o(a,function(i){var n=i?i.responseText:"";t.__JSONP_DATA&&(n=t.__JSONP_DATA,delete t.__JSONP_DATA),s.runServiceCallback.call(s,e,t,n)},this.options.timeout,t.data,t.headers)}},t.prototype.runServiceCallback=function(t,e,i){var n=this,s=function(e){o||n.onServiceResult.call(n,t,e)},o=e.callback(s,i);o&&this.onServiceResult.call(this,t,o)},t.prototype.onServiceResult=function(t,e){e instanceof Error||e&&e.error?t.call(this,e,null):t.call(this,null,e)},t.prototype.runNextServiceOnError=function(t,e){if(t){this.logError(t);var i=this.getNextService();i?this.runService(i,this.runNextServiceOnError.bind(this)):this.completeService.call(this,this.callbackError,new Error("All services failed"))}else this.completeService.call(this,this.callbackComplete,e)},t.prototype.getCurrentServiceOpts=function(){var t=this.options.services[this.currentServiceIndex];return"string"==typeof t?{name:t}:"function"==typeof t?t():e.isPlainObject(t)?t:{}},t.prototype.completeService=function(t,e){this.currentServiceIndex=-1,t&&t(e)},t.prototype.logError=function(t){var e=this.currentServiceIndex,i=this.getServiceByIdx(e);console.error("The service["+e+"] ("+i.url+") responded with the following error",t)},t}(),t.Law=function(){function t(){this.initialise.apply(this,arguments)}var i={regionalLaw:!0,hasLaw:["AT","BE","BG","HR","CZ","CY","DK","EE","FI","FR","DE","EL","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","SK","SI","ES","SE","GB","UK"],revokable:["HR","CY","DK","EE","FR","DE","LV","LT","NL","PT","ES"],explicitAction:["HR","IT","ES"]};return t.prototype.initialise=function(t){e.deepExtend(this.options={},i),e.isPlainObject(t)&&e.deepExtend(this.options,t)},t.prototype.get=function(t){var e=this.options;return{hasLaw:e.hasLaw.indexOf(t)>=0,revokable:e.revokable.indexOf(t)>=0,explicitAction:e.explicitAction.indexOf(t)>=0}},t.prototype.applyLaw=function(t,e){var i=this.get(e);return i.hasLaw||(t.enabled=!1),this.options.regionalLaw&&(i.revokable&&(t.revokable=!0),i.explicitAction&&(t.dismissOnScroll=!1,t.dismissOnTimeout=!1)),t},t}(),t.initialise=function(e,i,n){var s=new t.Law(e.law);i||(i=function(){}),n||(n=function(){}),t.getCountryCode(e,function(n){delete e.law,delete e.location,n.code&&(e=s.applyLaw(e,n.code)),i(new t.Popup(e))},function(i){delete e.law,delete e.location,n(i,new t.Popup(e))})},t.getCountryCode=function(e,i,n){if(e.law&&e.law.countryCode)return void i({code:e.law.countryCode});if(e.location){var s=new t.Location(e.location);return void s.locate(function(t){i(t||{})},n)}i({})},t.utils=e,t.hasInitialised=!0,window.cookieconsent=t}}(window.cookieconsent||{}),window.SL=function(t){t=t.split(".");for(var e=SL;t.length;){var i=t.shift();e[i]||(e[i]={}),e=e[i]}return e},function(){function t(){s||(s=!0,e(),SL.helpers&&SL.helpers.PageLoader.hide(),SL.settings.init(),SL.keyboard.init(),SL.pointer.init(),SL.draganddrop.init(),SL.fonts.init(),SL.visibility.init(),"undefined"==typeof SLConfig&&(window.SLConfig={}),i(),n(),SL.warnings.init(),SL.promotions.init(),SL.deckthumbs.init())}function e(){var t=$("html");t.addClass("loaded"),SL.util.device.HAS_TOUCH&&t.addClass("touch"),SL.util.device.isMac()?t.addClass("ua-mac"):SL.util.device.isWindows()?t.addClass("ua-windows"):SL.util.device.isLinux()&&t.addClass("ua-linux"),SL.util.device.isiPhone()&&t.addClass("ua-iphone"),SL.util.device.isChrome()?t.addClass("ua-chrome"):SL.util.device.isSafari()?t.addClass("ua-safari"):SL.util.device.isFirefox()?t.addClass("ua-firefox"):SL.util.device.isIE()&&t.addClass("ua-ie"),window.navigator.standalone&&t.addClass("ua-standalone"),SL.util.device.getScrollBarWidth()>0&&t.addClass("has-visible-scrollbars")}function i(){"object"==typeof window.SLConfig&&(SLConfig.deck&&!SLConfig.deck.notes&&(SLConfig.deck.notes={}),SL.current_user=new SL.models.User(SLConfig.current_user),"object"==typeof SLConfig.deck&&(SL.current_deck=new SL.models.Deck(SLConfig.deck)),"object"==typeof SLConfig.theme&&(SL.current_theme=new SL.models.Theme(SLConfig.theme)),"object"==typeof SLConfig.team&&(SL.current_team=new SL.models.Team(SLConfig.team)))}function n(){var t=$("html");SL.util.hideAddressBar(),t.hasClass("home index")?SL.view=new SL.views.home.Index:t.hasClass("home explore")?SL.view=new SL.views.home.Explore:t.hasClass("home features")?SL.view=new SL.views.home.Features:t.hasClass("users show")?SL.view=new SL.views.users.Show:t.hasClass("decks show")?SL.view=new SL.views.decks.Show:t.hasClass("decks edit")?SL.view=new SL.editor.Editor:t.hasClass("decks edit-requires-upgrade")?SL.view=new SL.views.decks.EditRequiresUpgrade:t.hasClass("decks embed")?SL.view=new SL.views.decks.Embed:t.is(".decks.presenter-view")?SL.view=new SL.views.decks.Presenter:t.is(".decks.kiosk")?SL.view=new SL.views.decks.Kiosk:t.is(".decks.live-client")?SL.view=new SL.views.decks.LiveClient:t.is(".decks.live-server")?SL.view=new SL.views.decks.LiveServer:t.hasClass("speaker-view")?SL.view=new SL.views.decks.Speaker:t.hasClass("decks export")?SL.view=new SL.views.decks.Export:t.hasClass("decks print")?SL.view=new SL.views.decks.Print:t.hasClass("decks fullscreen")?SL.view=new SL.views.decks.Fullscreen:t.hasClass("decks review")?SL.view=new SL.views.decks.Review:t.hasClass("decks password")?SL.view=new SL.views.decks.Password:t.hasClass("teams-subscriptions-show")?SL.view=new SL.views.teams.subscriptions.Show:t.hasClass("registrations")&&(t.hasClass("edit")||t.hasClass("update"))?SL.view=new SL.views.devise.Edit:t.hasClass("registrations")||t.hasClass("team_registrations")||t.hasClass("sessions")||t.hasClass("passwords")||t.hasClass("invitations show")?SL.view=new SL.views.devise.All:t.hasClass("subscriptions new")||t.hasClass("subscriptions edit")?SL.view=new SL.views.subscriptions.New:t.hasClass("subscriptions show")?SL.view=new SL.views.subscriptions.Show:t.hasClass("subscriptions edit_period")?SL.view=new SL.views.subscriptions.EditPeriod:t.hasClass("teams-reactivate")?SL.view=new SL.views.teams.subscriptions.Reactivate:t.hasClass("teams-signup")?SL.view=new SL.views.teams.New:t.hasClass("teams edit")?SL.view=new SL.views.teams.teams.Edit:t.hasClass("teams edit_members")?SL.view=new SL.views.teams.teams.EditMembers:t.hasClass("teams show")?SL.view=new SL.views.teams.teams.Show:t.hasClass("themes edit")?SL.view=new SL.views.themes.Edit:t.hasClass("themes preview")?SL.view=new SL.views.themes.Preview:t.hasClass("pricing")?SL.view=new SL.views.statik.Pricing:t.hasClass("static")?SL.view=new SL.views.statik.All:t.hasClass("funnels")?SL.view=new SL.views.funnels.All:SL.view=new SL.views.Base}var s=!1;"complete"===document.readyState?setTimeout(t,1):"interactive"===document.readyState?(document.onreadystatechange=function(){"complete"==document.readyState&&setTimeout(t,1)},window.addEventListener("load",t)):(document.addEventListener("DOMContentLoaded",t),window.addEventListener("load",t))}(),SL("collections").Collection=Class.extend({init:function(t,e,i){this.factory=e,this.crud=i||{},this.changed=new signals.Signal,this.replaced=new signals.Signal,this.setData(t)},setData:function(t){var e=!!this.data&&"undefined"!=typeof this.data;if(this.data=t||[],"function"==typeof this.factory){var i=this.data;this.data=[];for(var n=0,s=i.length;n<s;n++){var o=i[n];o instanceof this.factory?this.data.push(i[n]):this.data.push(this.createModelInstance(i[n]))}}e&&this.replaced.dispatch()},appendData:function(t){var e=this.size();return this.setData(this.data.concat(t)),this.data.slice(e)},prependData:function(t){var e=this.size();return this.setData(t.concat(this.data)),this.data.slice(0,e)},find:function(t){for(var e=0,i=this.data.length;e<i;e++){var n=this.data[e];if(n===t)return e}return-1},contains:function(t){return this.find(t)!==-1},findByProperties:function(t){for(var e=0,i=this.data.length;e<i;e++){var n=this.data[e],s=!0;for(var o in t)t.hasOwnProperty(o)&&("function"==typeof n.get?n.get(o)!=t[o]&&(s=!1):n[o]!=t[o]&&(s=!1));if(s)return e}return-1},getByProperties:function(t){return this.data[this.findByProperties(t)]},getByID:function(t){return this.getByProperties({id:t})},remove:function(t){for(var e,i=0;i<this.data.length;i++)this.data[i]===t&&(e=this.data.splice(i,1)[0],i--);"undefined"!=typeof e&&this.changed.dispatch(null,[e])},removeByProperties:function(t){for(var e,i=this.findByProperties(t),n=0;i!==-1&&n++<1e3;)e=this.data.splice(i,1)[0],i=this.findByProperties(t);"undefined"!=typeof e&&this.changed.dispatch(null,[e])},removeByIndex:function(t){var e=this.data.splice(t,1);return"undefined"!=typeof e&&this.changed.dispatch(null,[e]),e},create:function(t,e){return new Promise(function(i,n){"function"==typeof this.factory?this.crud.create?$.ajax({type:"POST",context:this,url:e&&e.url?e.url:this.crud.create,data:t}).done(function(t){e&&e.model?(e.model.setAll(t),i(e.model)):e&&e.createModel===!1?i():i(this.createModel(t,e))}).fail(function(t){n(t)}):i(this.createModel(t,e)):n()}.bind(this))},createModel:function(t,e){if(e=$.extend({prepend:!1},e),"function"==typeof this.factory){var i=this.createModelInstance(t);return e.prepend?this.unshift(i):this.push(i),i}},createModelInstance:function(t,e){return new this.factory(t,e)},clear:function(){this.data.length=0,this.changed.dispatch()},swap:function(t,e){var i="number"==typeof t&&t>=0&&t<this.size(),n="number"==typeof e&&e>=0&&e<this.size();if(i&&n){var s=this.data[t],o=this.data[e];this.data[t]=o,this.data[e]=s}this.changed.dispatch()},shiftLeft:function(t){"number"==typeof t&&t>0&&this.swap(t,t-1)},shiftRight:function(t){"number"==typeof t&&t<this.size()-1&&this.swap(t,t+1)},at:function(t){return this.data[t]},first:function(){return this.at(0)},last:function(){return this.at(this.size()-1)},size:function(){return this.data.length},isEmpty:function(){return 0===this.size()},getUniqueName:function(t,e,i){for(var n=-1,s=0,o=this.data.length;s<o;s++){var a=this.data[s],r="function"==typeof a.get?a.get(e):a[e];if(r){var l=r.match(new RegExp("^"+t+"\\s?(\\d+)?$"));l&&2===l.length&&(n=Math.max(l[1]?parseInt(l[1],10):0,n))}}return n===-1?t+(i?" 1":""):t+" "+(n+1)},pushUnique:function(t){if(this.data.indexOf(t)===-1){var e=this.data.push(t);return this.changed.dispatch([t]),e}return this.data.length},toJSON:function(){return this.map(function(t){return"function"==typeof t.toJSON?t.toJSON():t})},destroy:function(){this.changed.dispose(),this.data=null},unshift:function(t){var e=this.data.unshift(t);return this.changed.dispatch(t),e},push:function(t){var e=this.data.push(t);return this.changed.dispatch([t]),e},pop:function(){var t=this.data.pop();return"undefined"!=typeof t&&this.changed.dispatch(null,[t]),t},map:function(t,e){return this.data.map(t,e)},some:function(t,e){return this.data.some(t,e)},filter:function(t,e){return this.data.filter(t,e)},reduce:function(t,e){return this.data.reduce(t,e)},forEach:function(t,e){return this.data.forEach(t,e)}}),SL("collections").Loadable=SL.collections.Collection.extend({init:function(){this._super.apply(this,arguments),this.loadStatus="",this.loadStarted=new signals.Signal,this.loadCompleted=new signals.Signal,this.loadFailed=new signals.Signal},load:function(){},unload:function(){this.loadXHR&&(this.loadXHR.abort(),this.loadXHR=null),this.loadStatus="",this.clear()},onLoadStarted:function(){this.loadStatus="loading",this.loadStarted.dispatch()},onLoadCompleted:function(){this.loadStatus="loaded",this.loadCompleted.dispatch()},onLoadFailed:function(){this.loadStatus="failed",this.loadFailed.dispatch()},isLoading:function(){return"loading"===this.loadStatus},isLoaded:function(){return"loaded"===this.loadStatus},destroy:function(){this.loadStarted.dispose(),this.loadCompleted.dispose(),this.loadFailed.dispose(),this._super()}}),SL("collections").Paginatable=SL.collections.Loadable.extend({init:function(){this._super.apply(this,arguments)},load:function(t){if(!this.isLoading())return this.listURL=t||this.crud.list,this.onLoadStarted(),new Promise(function(t,e){this.loadXHR=$.ajax({type:"GET",url:this.listURL,context:this}).done(function(e){this.totalResults=e.total,this.pagesLoaded=1,this.pagesTotal=1,e.total>e.results.length&&(this.pagesTotal=Math.ceil(e.total/e.results.length)),this.setData(e.results),this.loadXHR=null,this.onLoadCompleted(),t()}).fail(function(){this.loadXHR=null,this.onLoadFailed(),e()})}.bind(this))},hasNextPage:function(){return this.pagesLoaded<this.pagesTotal},loadNextPage:function(){return this.hasNextPage()?new Promise(function(t,e){var i=this.listURL;i+=/\?/i.test(i)?"&":"?",$.ajax({type:"GET",url:i+"page="+(this.pagesLoaded+1),context:this}).done(function(e){this.pagesLoaded+=1,t(this.appendData(e.results))}).fail(function(){e()})}.bind(this)):Promise.resolve([])},getTotalResults:function(){return this.totalResults},getLoadedResults:function(){return this.size()}}),SL("collections").Tags=SL.collections.Loadable.extend({init:function(t,e,i,n){i&&i.add_item&&i.remove_item||console.warn("Can't initialize Tag collection without valid add_item and remove_item endpoints."),n||console.warn("Can't initialize Tag collection without valid tagType."),this.tagType=n,this._super(t,e,$.extend({list:SL.endpoints.TAG_LIST(n),create:SL.endpoints.TAG_CREATE,update:SL.endpoints.TAG_UPDATE,"delete":SL.endpoints.TAG_DELETE},i)),this.associationChanged=new signals.Signal},load:function(){return new Promise(function(t,e){
this.loadCompleted.addOnce(t),this.loadFailed.addOnce(e),this.isLoading()||(this.onLoadStarted(),$.ajax({type:"GET",url:this.crud.list,context:this}).done(function(t){this.setData(t.results),this.onLoadCompleted()}).fail(function(){this.onLoadFailed()}))}.bind(this))},create:function(t,e){return this._super($.extend({tag:{name:this.getUniqueName("Tag","name",!0),tag_type:this.tagType}},t),e)},addTagTo:function(t,e){e.forEach(function(e){t.addItem(e)}),this.associationChanged.dispatch(t),$.ajax({type:"POST",url:this.crud.add_item(t.get("id")),context:this,data:{model_ids:e.map(function(t){return t.get("id")})}}).fail(function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative")})},removeTagFrom:function(t,e){e.forEach(function(e){t.removeItem(e)}),this.associationChanged.dispatch(t),$.ajax({type:"DELETE",url:this.crud.remove_item(t.get("id")),context:this,data:{model_ids:e.map(function(t){return t.get("id")})}}).fail(function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative")})},removeModelFromAllTags:function(t){this.forEach(function(e){e.hasItem(t)&&(e.removeItem(t),this.associationChanged.dispatch(e))},this)}}),SL("collections.collab").Comments=SL.collections.Loadable.extend({init:function(t,e){this._super(t,e||SL.models.collab.Comment,{list:SL.endpoints.COMMENTS_LIST(SL.current_deck.get("id")),create:SL.endpoints.COMMENTS_CREATE(SL.current_deck.get("id")),"delete":SL.endpoints.COMMENTS_DELETE(SL.current_deck.get("id"))})},load:function(t){if(!this.isLoading())return this.url=t||this.crud.list,this.onLoadStarted(),new Promise(function(t,e){this.loadXHR=$.ajax({type:"GET",url:this.url,context:this}).done(function(e){this.pagesLoaded=1,this.pagesTotal=1,e.total>e.results.length&&(this.pagesTotal=Math.ceil(e.total/e.results.length)),this.setData(e.results.reverse()),this.pageOffsetID=this.isEmpty()?null:this.first().get("id"),this.loadXHR=null,this.onLoadCompleted(),t()}).fail(function(){this.loadXHR=null,this.onLoadFailed(),e()})}.bind(this))},hasNextPage:function(){return this.pagesLoaded<this.pagesTotal},loadNextPage:function(){return this.hasNextPage()?new Promise(function(t,e){$.ajax({type:"GET",url:this.url+"?page="+this.pagesLoaded+"&offset_id="+this.pageOffsetID,context:this}).done(function(e){this.pagesLoaded+=1,t(this.prependData(e.results.reverse()))}).fail(function(){e()})}.bind(this)):Promise.resolve([])},create:function(t,e){e=$.extend({url:this.crud.create},e),e.model?e.model.setState(SL.models.collab.Comment.STATE_SAVING):e.model=this.createModel(t.comment);var i=JSON.parse(JSON.stringify(t));return delete i.comment.user_id,delete i.comment.created_at,this._super(i,e).then(function(){e.model.setState(SL.models.collab.Comment.STATE_SAVED)}.bind(this),function(){e.model.setState(SL.models.collab.Comment.STATE_FAILED)}.bind(this)),Promise.resolve(e.model)},retryCreate:function(t){return this.create({comment:t.toJSON()},{model:t})}}),SL("collections.collab").DeckUsers=SL.collections.Loadable.extend({init:function(t,e,i){this._super(t,e||SL.models.collab.DeckUser,i||{list:SL.endpoints.DECKUSER_LIST(SLConfig.deck.id),create:SL.endpoints.DECKUSER_CREATE(SLConfig.deck.id)})},load:function(){if(!this.isLoading())return this.onLoadStarted(),new Promise(function(t,e){$.ajax({type:"GET",url:this.crud.list,context:this}).done(function(e){this.setData(e.results),this.onLoadCompleted(),t()}).fail(function(){this.onLoadFailed(),e()})}.bind(this))},hasMoreThanOneEditor:function(){return this.getEditors().length>1},hasMoreThanOnePresentEditor:function(){return this.getPresentEditors().length>1},setEditing:function(t){this.forEach(function(e){e.set("editing",e.get("user_id")===t)})},getByUserID:function(t){return this.getByProperties({user_id:t})},getEditors:function(){return this.filter(function(t){return t.canEdit()&&t.isActive()})},getPresentEditors:function(){return this.filter(function(t){return t.canEdit()&&t.isOnline()})}}),SL("collections").DeckTags=SL.collections.Tags.extend({init:function(t,e,i){this._super(t,e||SL.models.Tag,i||{add_item:SL.endpoints.TAG_ADD_DECK,remove_item:SL.endpoints.TAG_REMOVE_DECK},"deck")}}),SL("collections").Decks=SL.collections.Paginatable.extend({init:function(t,e,i){this._super(t,e||SL.models.Deck,i||{list:SL.endpoints.DECK_LIST()})}}),SL("collections").MediaTags=SL.collections.Tags.extend({init:function(t,e,i){this._super(t,e||SL.models.Tag,i||{add_item:SL.endpoints.TAG_ADD_MEDIA,remove_item:SL.endpoints.TAG_REMOVE_MEDIA},"media")}}),SL("collections").Media=SL.collections.Loadable.extend({init:function(t,e,i){this._super(t,e||SL.models.Media,i||{list:SL.endpoints.MEDIA_LIST,update:SL.endpoints.MEDIA_UPDATE,create:SL.endpoints.MEDIA_CREATE,"delete":SL.endpoints.MEDIA_DELETE})},createModelInstance:function(t){return SL.models.Media.create(t,this.crud)},load:function(){this.isLoading()||(this.page=1,this.pagedResults=[],this.onLoadStarted(),this.loadNextPage())},loadNextPage:function(){1===this.page||this.page<=this.totalPages?$.ajax({type:"GET",url:this.crud.list+"?page="+this.page,context:this}).done(function(t){this.totalPages||(this.totalPages=Math.ceil(t.total/t.results.length)),this.pagedResults=this.pagedResults.concat(t.results),this.page+=1,this.loadNextPage()}).fail(function(){this.onLoadFailed()}):(this.setData(this.pagedResults),this.onLoadCompleted())},createSearchFilter:function(t){if(!t||""===t)return function(){return!1};var e=new RegExp(t,"i");return function(t){return!t.isTrashed()&&e.test(t.get("label"))}},getImages:function(){return this.filter(SL.models.Media.IMAGE.filter)},getVideos:function(){return this.filter(SL.models.Media.VIDEO.filter)}}),SL("collections").TeamInvites=SL.collections.Paginatable.extend({init:function(t,e){this._super(t,e||SL.models.Model,{list:SL.endpoints.TEAM_INVITATIONS_LIST})}}),SL("collections").TeamMediaTags=SL.collections.MediaTags.extend({init:function(t){this._super(t,SL.models.Tag,{list:SL.endpoints.TEAM_MEDIA_TAG_LIST,create:SL.endpoints.TEAM_MEDIA_TAG_CREATE,update:SL.endpoints.TEAM_MEDIA_TAG_UPDATE,"delete":SL.endpoints.TEAM_MEDIA_TAG_DELETE,add_item:SL.endpoints.TEAM_MEDIA_TAG_ADD_MEDIA,remove_item:SL.endpoints.TEAM_MEDIA_TAG_REMOVE_MEDIA},"media")},createModelInstance:function(t){return this._super(t,this.crud)}}),SL("collections").TeamMedia=SL.collections.Media.extend({init:function(t){this._super(t,SL.models.Media,{list:SL.endpoints.TEAM_MEDIA_LIST,create:SL.endpoints.TEAM_MEDIA_CREATE,read:SL.endpoints.TEAM_MEDIA_READ,update:SL.endpoints.TEAM_MEDIA_UPDATE,"delete":SL.endpoints.TEAM_MEDIA_DELETE})},createModelInstance:function(t){return SL.models.Media.create(t,this.crud)}}),SL("collections").TeamMembers=SL.collections.Paginatable.extend({init:function(t,e){this._super(t,e||SL.models.User,{list:SL.endpoints.TEAM_MEMBERS_LIST})}}),SL("models").Model=Class.extend({init:function(t){this.watchlist={},this.setData(t)},setData:function(t){this.data=t||{}},getData:function(){return this.data},setAll:function(t){for(var e in t)this.set(e,t[e])},set:function(t,e){this.data[t]=e,this.watchlist[t]&&this.watchlist[t].dispatch(e)},get:function(t){if("string"==typeof t&&/\./.test(t)){for(var e=t.split("."),i=this.data;e.length&&i;)t=e.shift(),i=i[t];return i}return this.data[t]},has:function(t){var e=this.get(t);return!!e||e===!1||0===e},watch:function(t,e){this.watchlist[t]||(this.watchlist[t]=new signals.Signal),this.watchlist[t].add(e)},unwatch:function(t,e){this.watchlist[t]&&this.watchlist[t].remove(e)},toJSON:function(){return JSON.parse(JSON.stringify(this.data))},destroy:function(){for(var t in this.watchlist)this.watchlist[t].dispose(),delete this.watchlist[t]}}),SL("models").AccessToken=SL.models.Model.extend({init:function(t){this._super(t)},save:function(t){var e={access_token:{}};return t?t.forEach(function(t){e.access_token[t]=this.get(t)}.bind(this)):e.access_token=this.toJSON(),$.ajax({url:SL.endpoints.ACCESS_TOKENS_UPDATE(this.get("deck_id"),this.get("id")),type:"PUT",data:e})},destroy:function(){return $.ajax({url:SL.endpoints.ACCESS_TOKENS_DELETE(this.get("deck_id"),this.get("id")),type:"DELETE"})},clone:function(){return new SL.models.AccessToken(JSON.parse(JSON.stringify(this.data)))}}),SL("models.collab").Comment=SL.models.Model.extend({init:function(t){this._super(t),this.state=this.has("id")?SL.models.collab.Comment.STATE_SAVED:SL.models.collab.Comment.STATE_SAVING,this.stateChanged=new signals.Signal},setState:function(t){this.state=t,this.stateChanged.dispatch(this)},getState:function(){return this.state},getDisplayName:function(){return this.get("name")||this.get("username")},clone:function(){return new SL.models.collab.Comment(JSON.parse(JSON.stringify(this.data)))},save:function(t){var e={comment:{}};return t?t.forEach(function(t){e.comment[t]=this.get(t)}.bind(this)):e.comment=this.toJSON(),$.ajax({url:SL.endpoints.COMMENTS_UPDATE(SL.current_deck.get("id"),this.get("id")),type:"PUT",data:e})},destroy:function(){return $.ajax({url:SL.endpoints.COMMENTS_DELETE(SL.current_deck.get("id"),this.get("id")),type:"DELETE"})}}),SL.models.collab.Comment.STATE_SAVED="saved",SL.models.collab.Comment.STATE_SAVING="saving",SL.models.collab.Comment.STATE_FAILED="failed",SL("models.collab").DeckUser=SL.models.Model.extend({init:function(t){this._super(t),this.has("status")||this.set("status",SL.models.collab.DeckUser.STATUS_DISCONNECTED)},getDisplayName:function(){return this.get("name")||this.get("username")},canComment:function(){return!0},canEdit:function(){return[SL.models.collab.DeckUser.ROLE_OWNER,SL.models.collab.DeckUser.ROLE_ADMIN,SL.models.collab.DeckUser.ROLE_EDITOR].indexOf(this.get("role"))!==-1},isAdmin:function(){return[SL.models.collab.DeckUser.ROLE_OWNER,SL.models.collab.DeckUser.ROLE_ADMIN].indexOf(this.get("role"))!==-1},isOnline:function(){return this.get("status")&&this.get("status")!==SL.models.collab.DeckUser.STATUS_DISCONNECTED},isIdle:function(){return this.get("status")===SL.models.collab.DeckUser.STATUS_IDLE},isEditing:function(){return this.get("editing")===!0},isActive:function(){return this.get("active")===!0},isCurrentUser:function(){return this.get("user_id")===SL.current_user.get("id")},clone:function(){return new SL.models.collab.DeckUser(JSON.parse(JSON.stringify(this.data)))},save:function(t){var e={user:{}};return t?t.forEach(function(t){e.user[t]=this.get(t)}.bind(this)):e.user=this.toJSON(),$.ajax({url:SL.endpoints.DECKUSER_UPDATE(SL.current_deck.get("id"),this.get("user_id")),type:"PUT",data:e})},destroy:function(){return $.ajax({url:SL.endpoints.DECKUSER_DELETE(SL.current_deck.get("id"),this.get("user_id")),type:"DELETE"})}}),SL.models.collab.DeckUser.ROLE_OWNER="owner",SL.models.collab.DeckUser.ROLE_ADMIN="admin",SL.models.collab.DeckUser.ROLE_EDITOR="editor",SL.models.collab.DeckUser.ROLE_VIEWER="viewer",SL.models.collab.DeckUser.STATUS_DISCONNECTED="disconnected",SL.models.collab.DeckUser.STATUS_VIEWING="viewing",SL.models.collab.DeckUser.STATUS_IDLE="idle",SL("models").Customer=SL.models.Model.extend({init:function(t){this._super(t)},isTrial:function(){return"trialing"===this.get("subscription.status")},hasActiveSubscription:function(){return this.has("subscription")&&!this.get("subscription.cancel_at_period_end")},hasCoupon:function(){return this.has("subscription")&&this.has("subscription.coupon_code")},getNextInvoiceDate:function(){return this.get("next_charge")},getNextInvoiceSum:function(){return(parseFloat(this.get("next_charge_amount"))/100).toFixed(2)},clone:function(){return new SL.models.Customer(JSON.parse(JSON.stringify(this.data)))}}),SL("models").Deck=SL.models.Model.extend({init:function(t){this._super(t),$.extend(this,this.data),this.user=new SL.models.User(this.data.user),this.user_settings=new SL.models.UserSettings(this.data.user.settings)},isPaid:function(){return this.user.isPaid()},isPro:function(){return this.user.isPro()},isVisibilityAll:function(){return this.get("visibility")===SL.models.Deck.VISIBILITY_ALL},isVisibilitySelf:function(){return this.get("visibility")===SL.models.Deck.VISIBILITY_SELF},isVisibilityTeam:function(){return this.get("visibility")===SL.models.Deck.VISIBILITY_TEAM},belongsTo:function(t){return this.get("user.id")===t.get("id")},getURL:function(t){t=$.extend({protocol:document.location.protocol,token:null,view:null},t);var e=this.get("user.username"),i=this.get("slug")||this.get("id"),n=t.protocol+"//"+document.location.host+SL.routes.DECK(e,i);return t.view&&(n+="/"+t.view),t.token&&(n+="?token="+t.token.get("token")),n},save:function(t){var e={deck:{}};return t&&t.forEach(function(t){e.deck[t]=this.get(t)}.bind(this)),$.ajax({url:SL.endpoints.UPDATE_DECK(this.get("id")),type:"PUT",data:e})},clone:function(){return new SL.models.Deck(JSON.parse(JSON.stringify(this.data)))}}),SL("models").Deck.VISIBILITY_SELF="self",SL("models").Deck.VISIBILITY_TEAM="team",SL("models").Deck.VISIBILITY_ALL="all",SL("models").Media=SL.models.Model.extend({uploadStatus:"",uploadFile:null,init:function(t,e,i,n){this._super(t),this.crud=$.extend({create:SL.endpoints.MEDIA_CREATE,read:SL.endpoints.MEDIA_READ,update:SL.endpoints.MEDIA_UPDATE,"delete":SL.endpoints.MEDIA_DELETE},e),i?(this.uploadStatus=SL.models.Media.STATUS_UPLOAD_WAITING,this.uploadFile=i,this.uploadFilename=n||i.name||"Untitled",this.set("content_type",this.uploadFile.type)):this.uploadStatus=SL.models.Media.STATUS_UPLOADED,this.uploadStarted=new signals.Signal,this.uploadProgressed=new signals.Signal,this.uploadCompleted=new signals.Signal,this.uploadFailed=new signals.Signal},upload:function(){/\.svg$/i.test(this.uploadFile.name)&&window.FileReader?(SL.analytics.trackEditor("Media: SVG upload started"),this.reader=new window.FileReader,this.reader.addEventListener("abort",this.uploadValidated.bind(this)),this.reader.addEventListener("error",this.uploadValidated.bind(this)),this.reader.addEventListener("load",function(t){var e=t.target.result;e&&e.length&&(e=e.replace(/\<(\?xml|(\!DOCTYPE[^\>\[]+(\[[^\]]+)?))+[^>]+\>/g,""),e=e.replace(/\s{2,}/g," "));var i=$("<div>"+e+"</div>").find("svg").get(0);if(i){$(i).parent().find("*").contents().each(function(){8===this.nodeType&&$(this).remove()}),$(i).find("script").remove(),$(i).removeAttr("content"),i.querySelectorAll("*").forEach(function(t){Array.prototype.forEach.call(t.attributes,function(e){/<|>/g.test(e.value)&&t.setAttribute(e.name,SL.util.escapeHTMLEntities(e.value))})});var n=i.getAttribute("width"),s=i.getAttribute("height"),o=i.hasAttribute("xmlns"),a=i.hasAttribute("viewBox");if(hasWidthAndHeight=n&&s,o||i.setAttribute("xmlns","http://www.w3.org/2000/svg"),hasWidthAndHeight&&(/[^\d]/g.test(n)||/[^\d]/g.test(s))&&(i.setAttribute("width",parseFloat(n)),i.setAttribute("height",parseFloat(s))),!a&&hasWidthAndHeight&&(i.setAttribute("viewBox",[0,0,i.getAttribute("width"),i.getAttribute("height")].join(" ")),a=!0),!hasWidthAndHeight&&a){var r=i.getAttribute("viewBox").split(" ");4===r.length&&(i.setAttribute("width",r[2]),i.setAttribute("height",r[3]),hasWidthAndHeight=!0)}if(a&&hasWidthAndHeight){var l='<?xml version="1.0"?>\n'+i.parentNode.innerHTML;l=l.replace(/<br>/g,"<br/>"),this.uploadFilename=this.uploadFile.name||"image.svg",this.uploadFile=new Blob([l],{type:"image/svg+xml"}),this.uploadValidated()}else this.uploadStatus=SL.models.Media.STATUS_UPLOAD_FAILED,this.uploadFailed.dispatch("SVG error: missing viewBox or width/height"),SL.analytics.trackEditor("Media: SVG upload error","missing viewBox or w/h")}else this.uploadStatus=SL.models.Media.STATUS_UPLOAD_FAILED,this.uploadFailed.dispatch("Invalid SVG: missing &lt;svg&gt; element"),SL.analytics.trackEditor("Media: SVG upload error","missing svg element");this.reader=null}.bind(this)),this.reader.readAsText(this.uploadFile,"UTF-8")):this.uploadValidated()},createUploader:function(t){return new SL.helpers.FileUploader($.extend({timeout:SL.config.IMAGE_UPLOAD_TIMEOUT,endpoint:this.crud.create,formdataFields:{type:this.isVideo()?"Video":"Image"}},t))},uploadValidated:function(){return!this.uploader&&(this.uploader=this.createUploader({media:this,file:this.uploadFile,filename:this.uploadFilename}),this.uploader.progressed.add(this.onUploadProgress.bind(this)),this.uploader.succeeded.add(this.onUploadSuccess.bind(this)),this.uploader.failed.add(this.onUploadError.bind(this)),"function"==typeof this.uploader.start?this.uploader.start():this.uploader.upload(),this.uploadStatus=SL.models.Media.STATUS_UPLOADING,void this.uploadStarted.dispatch())},onUploadProgress:function(t){this.uploadProgressed.dispatch(t)},onUploadSuccess:function(t){this.uploader.destroy(),this.uploader=null,this.setAll(t),this.uploadStatus=SL.models.Media.STATUS_UPLOADED,this.uploadCompleted.dispatch()},onUploadError:function(){this.uploader.destroy(),this.uploader=null,this.uploadStatus=SL.models.Media.STATUS_UPLOAD_FAILED,this.uploadFailed.dispatch()},isLoading:function(){return!!this.reloadXHR},isWaitingToUpload:function(){return this.uploadStatus===SL.models.Media.STATUS_UPLOAD_WAITING},isUploading:function(){return this.uploadStatus===SL.models.Media.STATUS_UPLOADING},isUploaded:function(){return this.uploadStatus===SL.models.Media.STATUS_UPLOADED},isUploadFailed:function(){return this.uploadStatus===SL.models.Media.STATUS_UPLOAD_FAILED},isImage:function(){return/^image\//.test(this.get("content_type"))},isSVG:function(){return/^image\/svg/.test(this.get("content_type"))},isVideo:function(){return/^video\//.test(this.get("content_type"))||/video/i.test(this.get("type"))},isTrashed:function(){return this.get("hidden")===!0},hasPostProcessingStep:function(){return this.isVideo()},clone:function(){return new SL.models.Media(JSON.parse(JSON.stringify(this.data)))},load:function(){return this.reloadXHR||(this.reloadXHR=$.ajax({url:this.crud.read(this.get("id")),type:"GET",context:this}).done(function(t){this.reloadXHR=null,this.setAll(t)}).always(function(){this.reloadXHR=null})),this.reloadXHR},save:function(t){var e={media:{}};return t?t.forEach(function(t){e.media[t]=this.get(t)}.bind(this)):e.media=this.toJSON(),$.ajax({url:this.crud.update(this.get("id")),type:"PUT",data:e})},destroy:function(){return this.uploadFile=null,this.uploadStarted&&this.uploadStarted.dispose(),this.uploadProgressed&&this.uploadProgressed.dispose(),this.uploadCompleted&&this.uploadCompleted.dispose(),this.uploadFailed&&this.uploadFailed.dispose(),this.uploader&&(this.uploader.destroy(),this.uploader=null),this.reloadXHR&&(this.reloadXHR.abort(),this.reloadXHR=null),$.ajax({url:this.crud["delete"](this.get("id")),type:"DELETE"})}}),SL.models.Media.STATUS_UPLOAD_WAITING="waiting",SL.models.Media.STATUS_UPLOADING="uploading",SL.models.Media.STATUS_UPLOADED="uploaded",SL.models.Media.STATUS_UPLOAD_FAILED="upload-failed",SL.models.Media.IMAGE={id:"image",type:"Image",filter:function(t){return!t.isTrashed()&&t.isImage()}},SL.models.Media.SVG={id:"svg",filter:function(t){return!t.isTrashed()&&t.isSVG()}},SL.models.Media.VIDEO={id:"video",type:"Video",filter:function(t){return!t.isTrashed()&&t.isVideo()}},SL.models.Media.ALL={id:"all",filter:function(t){return!t.isTrashed()}},SL.models.Media.TRASHED={id:"trashed",filter:function(t){return t.isTrashed()}},SL.models.Media.create=function(t){var t=t||{},e=SL.models[t&&"string"==typeof t.type?t.type:"Image"];"function"!=typeof e&&(e=SL.models.Media);var i=[null].concat(Array.prototype.slice.call(arguments));return new(Function.prototype.bind.apply(e,i))},SL.models.Media.getTypeFromContentType=function(t){return/^video\//.test(t)?"Video":/^audio\//.test(t)?"Audio":"Image"},SL("models").Tag=SL.models.Model.extend({init:function(t,e){this._super(t),this.crud=$.extend({update:SL.endpoints.TAG_UPDATE,"delete":SL.endpoints.TAG_UPDATE},e);var i=this.get("tag_type");"deck"===i?this.itemArray=this.data.decks:"media"===i?this.itemArray=this.data.medias:console.warn('Invalid or missing tag_type "'+i+'".')},createFilter:function(){var t=this;return function(e){return!e.isTrashed()&&t.hasItem(e)}},hasItem:function(t){return this.itemArray.indexOf(t.get("id"))!==-1},addItem:function(t){this.hasItem(t)||this.itemArray.push(t.get("id"))},removeItem:function(t){for(var e="object"==typeof t?t.get("id"):t,i=0;i<this.itemArray.length;i++)this.itemArray[i]===e&&(this.itemArray.splice(i,1),i--)},getItems:function(){return this.itemArray},itemCount:function(){return this.itemArray.length},clone:function(){return new SL.models.Tag(JSON.parse(JSON.stringify(this.data)))},save:function(t){var e={tag:{}};return t?t.forEach(function(t){e.tag[t]=this.get(t)}.bind(this)):e.tag=this.toJSON(),$.ajax({url:this.crud.update(this.get("id")),type:"PUT",data:e,context:this}).done(function(t){t&&"string"==typeof t.slug&&this.set("slug",t.slug),t&&"string"==typeof t.name&&this.set("name",t.name)})},destroy:function(){return $.ajax({url:this.crud["delete"](this.get("id")),type:"DELETE"})}}),SL("models").Team=SL.models.Model.extend({init:function(t){if(this._super(t),"object"==typeof this.data.themes)for(var e=0,i=this.data.themes.length;e<i;e++)this.data.themes[e]=new SL.models.Theme(this.data.themes[e]);this.set("themes",new SL.collections.Collection(this.data.themes))},hasThemes:function(){var t=this.get("themes");return t&&t.size()>0},getDefaultTheme:function(){return this.get("themes").getByProperties({id:this.get("default_theme_id")})},getCostPerUser:function(){var t=this.get("account_billing_period"),e=this.get("account_cost_per_user");return"yearly"===t?"$"+e+"/year":"monthly"===t?"$"+e+"/month":"N/A"},isManuallyUpgraded:function(){return!!this.get("manually_upgraded")},allowPublicDecks:function(){return!!this.get("allow_public_decks")},save:function(t){var e={team:{}};return t?t.forEach(function(t){e.team[t]=this.get(t)}.bind(this)):e.team=this.toJSON(),$.ajax({url:SL.endpoints.UPDATE_TEAM,type:"PUT",data:e})},clone:function(){return new SL.models.Team(JSON.parse(JSON.stringify(this.data)))}}),SL("models").Template=SL.models.Model.extend({init:function(t){this._super(t)},isAvailableForTheme:function(t){return t.hasSlideTemplate(this.get("id"))||this.isAvailableForAllThemes()},isAvailableForAllThemes:function(){var t=this.get("id");return!SL.current_user.getThemes().some(function(e){return e.hasSlideTemplate(t)})}}),SL("models").ThemeSnippet=SL.models.Model.extend({init:function(t){this._super(t),this.has("title")||this.set("title",""),this.has("template")||this.set("template","")},templatize:function(t){var e=this.get("template");return e&&(e=e.split(SL.models.ThemeSnippet.TEMPLATE_SELECTION_TAG).join(""),t.forEach(function(t){e=e.replace(t.string,t.value||t.defaultValue)})),e},getTemplateVariables:function(){var t=this.get("template");if(t){t=t.split(SL.models.ThemeSnippet.TEMPLATE_SELECTION_TAG).join("");var e=t.match(SL.models.ThemeSnippet.TEMPLATE_VARIABLE_REGEX);if(e)return e=e.map(function(t){var e=t.split(SL.models.ThemeSnippet.TEMPLATE_VARIABLE_DIVIDER),i={string:t,label:e[0]||"",defaultValue:e[1]||""};return i.label=i.label.trim(),i.defaultValue=i.defaultValue.trim(),i.label=i.label.replace(SL.models.ThemeSnippet.TEMPLATE_VARIABLE_OPENER,""),i.label=i.label.replace(SL.models.ThemeSnippet.TEMPLATE_VARIABLE_CLOSER,""),i.defaultValue=i.defaultValue.replace(SL.models.ThemeSnippet.TEMPLATE_VARIABLE_OPENER,""),i.defaultValue=i.defaultValue.replace(SL.models.ThemeSnippet.TEMPLATE_VARIABLE_CLOSER,""),i.label&&/\[IMAGE\]$/.test(i.label)?(i.label=i.label.replace(/\[IMAGE\]$/,""),i.inputType="image"):i.label&&/\[VIDEO\]$/.test(i.label)&&(i.label=i.label.replace(/\[VIDEO\]$/,""),i.inputType="video"),i})}return[]},templateHasVariables:function(){return this.getTemplateVariables().length>0},templateHasSelection:function(){var t=this.get("template");return!!t&&t.indexOf(SL.models.ThemeSnippet.TEMPLATE_SELECTION_TAG)>-1},isEmpty:function(){return!this.get("title")&&!this.get("template")}}),SL.models.ThemeSnippet.TEMPLATE_VARIABLE_OPENER="{{",SL.models.ThemeSnippet.TEMPLATE_VARIABLE_CLOSER="}}",SL.models.ThemeSnippet.TEMPLATE_VARIABLE_DIVIDER="::",SL.models.ThemeSnippet.TEMPLATE_VARIABLE_REGEX=/\{\{.*?\}\}/gi,SL.models.ThemeSnippet.TEMPLATE_SELECTION_TAG="{{selection}}",SL("models").Theme=SL.models.Model.extend({init:function(t){this._super(t),this.formatData(),this.loading=!1},load:function(t){return this.loading=!0,t="string"==typeof t?t:SL.endpoints.THEMES_READ(this.get("id")),$.ajax({type:"GET",url:t,context:this}).done(function(t){$.extend(this.data,t),this.formatData()}).always(function(){this.loading=!1})},formatData:function(){this.has("name")||this.set("name","Untitled"),this.has("width")||this.set("width",SL.config.DEFAULT_SLIDE_WIDTH),this.has("height")||this.set("height",SL.config.DEFAULT_SLIDE_HEIGHT),this.has("font")||this.set("font",SL.config.DEFAULT_THEME_FONT),this.has("color")||this.set("color",SL.config.DEFAULT_THEME_COLOR),this.has("transition")||this.set("transition",SL.config.DEFAULT_THEME_TRANSITION),this.has("background_transition")||this.set("background_transition",SL.config.DEFAULT_THEME_BACKGROUND_TRANSITION),this.data.slide_template_ids instanceof SL.collections.Collection||this.set("slide_template_ids",new SL.collections.Collection(this.data.slide_template_ids)),this.data.snippets instanceof SL.collections.Collection||("string"==typeof this.data.snippets&&this.data.snippets.length>0&&(this.data.snippets=JSON.parse(this.data.snippets)),this.set("snippets",new SL.collections.Collection(this.data.snippets,SL.models.ThemeSnippet))),this.data.palette instanceof Array||("string"==typeof this.data.palette&&this.data.palette.length>0?(this.data.palette=this.data.palette.split(","),this.data.palette=this.data.palette.map(function(t){return t.trim()})):this.data.palette=[])},hasSlideTemplate:function(t){return this.get("slide_template_ids").contains(t)},addSlideTemplate:function(t){var e=this.get("slide_template_ids");return t.forEach(function(t){e.contains(t)||e.push(t)}),$.ajax({type:"POST",url:SL.endpoints.THEME_ADD_SLIDE_TEMPLATE(this.get("id")),context:this,data:{slide_template_ids:t}})},removeSlideTemplate:function(t){var e=this.get("slide_template_ids");return t.forEach(function(t){e.remove(t)}),$.ajax({type:"DELETE",url:SL.endpoints.THEME_REMOVE_SLIDE_TEMPLATE(this.get("id")),context:this,data:{slide_template_ids:t}})},hasThumbnail:function(){return!!this.get("thumbnail_url")},hasJavaScript:function(){return!!this.get("js")},hasPalette:function(){return this.get("palette").length>0},isFontDeprecated:function(){var t=this.get("font");return SL.config.THEME_FONTS.some(function(e){return e.id===t&&e.deprecated===!0})},isTransitionDeprecated:function(){var t=this.get("transition");return SL.config.THEME_TRANSITIONS.some(function(e){return e.id===t&&e.deprecated===!0})},isBackgroundTransitionDeprecated:function(){var t=this.get("background_transition");return SL.config.THEME_BACKGROUND_TRANSITIONS.some(function(e){return e.id===t&&e.deprecated===!0})},isLoading:function(){return this.loading},loadCustomFonts:function(){SL.fonts&&(this.has("font_typekit")&&SL.fonts.loadTypekitFont(this.get("font_typekit")),this.has("font_google")&&SL.fonts.loadGoogleFont(this.get("font_google")))},clone:function(){return new SL.models.Theme(JSON.parse(JSON.stringify(this.toJSON())))},toJSON:function(){return{id:this.get("id"),name:this.get("name"),width:this.get("width"),height:this.get("height"),center:this.get("center"),rolling_links:this.get("rolling_links"),font:this.get("font"),color:this.get("color"),transition:this.get("transition"),background_transition:this.get("background_transition"),font_typekit:this.get("font_typekit"),font_google:this.get("font_google"),html:this.get("html"),less:this.get("less"),css:this.get("css"),js:this.get("js"),snippets:this.has("snippets")?JSON.stringify(this.get("snippets").toJSON()):null,palette:this.has("palette")?this.get("palette").join(","):null}}}),SL("models").Theme.fromDeck=function(t){return new SL.models.Theme({id:t.theme_id,name:"",width:t.width,height:t.height,center:t.center,rolling_links:t.rolling_links,font:t.theme_font,color:t.theme_color,transition:t.transition,background_transition:t.background_transition,font_typekit:t.font_typekit,font_google:t.font_google,snippets:"",palette:[]})},SL("models").UserMembership=SL.models.Model.extend({init:function(t){this._super(t)},isAdmin:function(){return this.get("role")===SL.models.UserMembership.ROLE_ADMIN},isOwner:function(){return this.get("role")===SL.models.UserMembership.ROLE_OWNER},clone:function(){return new SL.models.UserMembership(JSON.parse(JSON.stringify(this.data)))}}),SL.models.UserMembership.ROLE_OWNER="owner",SL.models.UserMembership.ROLE_ADMIN="admin",SL.models.UserMembership.ROLE_MEMBER="member",SL("models").UserPrivileges=SL.models.Model.extend({init:function(t,e){this._super(t,e),this.user=e},privateDecks:function(){return this.user.isPaid()},privateLinks:function(){return this.user.isPro()||this.user.isEnterprise()},customCSS:function(){return this.user.isPro()||this.user.isEnterprise()},hideEmbedFooter:function(){return this.user.isPaid()},embedWhitelist:function(){return this.user.isPro()||this.user.isEnterprise()},deckTemplateSelector:function(){return"templates"===SL.util.getQuery().beta}}),SL("models").UserSettings=SL.models.Model.extend({init:function(t){this._super(t),this.has("present_controls")||this.set("present_controls",SL.config.PRESENT_CONTROLS_DEFAULT),this.has("present_upsizing")||this.set("present_upsizing",SL.config.PRESENT_UPSIZING_DEFAULT),this.has("export_controls")||this.set("export_controls",SL.config.DEFAULT_EXPORT_CONTROLS),this.has("export_separate_fragments")||this.set("export_separate_fragments",SL.config.DEFAULT_EXPORT_SEPARATE_FRAGMENTS),this.has("editor_fixed_notes")||this.set("editor_fixed_notes",SL.config.DEFAULT_EDITOR_FIXED_NOTES)},save:function(t){var e={user_settings:{}};return t?t.forEach(function(t){e.user_settings[t]=this.get(t)}.bind(this)):e.user_settings=this.toJSON(),$.ajax({url:SL.endpoints.UPDATE_USER_SETTINGS,type:"PUT",data:e})},getMediaSourceList:function(){return(this.get("media_sources")||"").split(",").map(function(t){return t.trim()}).filter(function(t){return""!==t})},clone:function(){return new SL.models.UserSettings(JSON.parse(JSON.stringify(this.data)))}}),SL("models").User=SL.models.Model.extend({init:function(t){this._super(t),$.extend(this,this.data),this.settings=new SL.models.UserSettings(this.data.settings),this.privileges=new SL.models.UserPrivileges(this.data,this),this.data.membership&&(this.membership=new SL.models.UserMembership(this.data.membership))},isFree:function(){return this.account_type===SL.models.User.ACCOUNT_TYPE_DEFAULT},isPaid:function(){return!this.isFree()},isLite:function(){return this.account_type===SL.models.User.ACCOUNT_TYPE_LITE},isPro:function(){return this.account_type===SL.models.User.ACCOUNT_TYPE_PRO},isEnterprise:function(){return this.account_type===SL.models.User.ACCOUNT_TYPE_ENTERPRISE},isEnterpriseManager:function(){return this.hasMembership()&&(this.membership.isAdmin()||this.membership.isOwner())},hasMembership:function(){return!!this.membership},hasStorageLimit:function(){return this.get("storage_limit")>0},isExceedingStorageLimit:function(){return this.get("storage_used")>this.get("storage_limit")},isMemberOfCurrentTeam:function(){return!(!SL.current_team||SL.current_team.get("id")!==this.get("team_id"))},isManuallyUpgraded:function(){return!!this.manually_upgraded},hasThemes:function(){if(SL.current_team)return SL.current_team.hasThemes()},getThemes:function(){return SL.current_team?SL.current_team.get("themes"):new SL.collections.Collection},hasDefaultTheme:function(){return!!this.getDefaultTheme()},getDefaultTheme:function(){var t=this.getThemes();return SL.current_team?t.getByProperties({id:SL.current_team.get("default_theme_id")}):t.getByProperties({id:this.default_theme_id})},getProfileURL:function(){return"/"+this.username},getProfilePictureURL:function(){return this.thumbnail_url},getNameOrSlug:function(){return this.name||this.username},updateStorageUsed:function(){return new Promise(function(t,e){$.ajax({type:"GET",url:SL.endpoints.MEDIA_USAGE,context:this}).done(function(i){"number"==typeof i.bytes?(this.set("storage_used",i.bytes),t()):e()}).fail(e)}.bind(this))}}),SL.models.User.ACCOUNT_TYPE_PRO="pro",SL.models.User.ACCOUNT_TYPE_LITE="lite",SL.models.User.ACCOUNT_TYPE_DEFAULT="default",SL.models.User.ACCOUNT_TYPE_ENTERPRISE="enterprise",SL("models").Video=SL.models.Media.extend({videoStatus:null,init:function(){this._super.apply(this,arguments),this.processingStarted=new signals.Signal,this.processingCompleted=new signals.Signal,this.processingFailed=new signals.Signal,this.onStatusChanged=this.onStatusChanged.bind(this),this.isProcessed()||(this.watch("status",this.onStatusChanged),this.startPollingProcessingStatus())},createUploader:function(t){return new SL.helpers.MediaUploader($.extend({type:"Video",timeout:SL.config.VIDEO_UPLOAD_TIMEOUT,
endpoint:this.crud.create},t))},startPollingProcessingStatus:function(){this.isProcessing()&&!this.processingPoll&&(this.processingStarted.dispatch(),this.processingPoll=new SL.helpers.PollJob({interval:3e3,timeout:SL.config.VIDEO_TRANSCODE_TIMEOUT,invokeAsap:!0}),this.processingPoll.polled.add(this.onProcessingStatusPoll.bind(this)),this.processingPoll.ended.add(this.onProcessingFailed.bind(this)),this.processingPoll.start())},onUploadSuccess:function(){this._super.apply(this,arguments),this.startPollingProcessingStatus()},onStatusChanged:function(){this.isProcessed()?this.onProcessingSuccess():this.isProcessingFailed()&&this.onProcessingFailed()},onProcessingStatusPoll:function(){this.load().then(null,function(t){t&&404===t.status&&this.processingPoll.stop()}.bind(this))},onProcessingSuccess:function(){this.unwatch("status",this.onStatusChanged),this.processingCompleted.dispatch(),this.processingPoll.stop()},onProcessingFailed:function(){this.unwatch("status",this.onStatusChanged),this.processingFailed.dispatch(),this.processingPoll.stop()},isProcessing:function(){return this.isUploaded()&&!this.isProcessed()&&!this.isProcessingFailed()},isProcessed:function(){return"complete"===this.get("status")},isProcessingFailed:function(){return"error"===this.get("status")},clone:function(){return new SL.models.Media(JSON.parse(JSON.stringify(this.data)))},destroy:function(){return clearTimeout(this.pollStatusTimeout),this.processingStarted&&this.processingStarted.dispose(),this.processingCompleted&&this.processingCompleted.dispose(),this.processingFailed&&this.processingFailed.dispose(),this.processingPoll&&(this.processingPoll.destroy(),this.processingPoll=null),this._super.apply(this,arguments)}}),SL("data").templates={NEW_DECK_TEMPLATE:{html:["<section>",'<div class="sl-block" data-block-type="text" style="width: 84%; left: 8%; top: 34%;">','<div class="sl-block-content" data-placeholder-tag="h1" data-placeholder-text="Title Text">',"<h1>Title Text</h1>","</div>","</div>","</section>"].join("")},DEFAULT_TEMPLATES:[{html:["<section>",'<div class="sl-block" data-block-type="text" style="width: 84%; left: 8%; top: 38%;">','<div class="sl-block-content" data-placeholder-tag="h1" data-placeholder-text="Title Text">',"<h1>Title Text</h1>","</div>","</div>","</section>"].join("")},{html:["<section>",'<div class="sl-block" data-block-type="text" style="width: 84%; left: 8%; top: 27%;">','<div class="sl-block-content" data-placeholder-tag="h1" data-placeholder-text="Title Text">',"<h1>Title Text</h1>","</div>","</div>",'<div class="sl-block" data-block-type="text" style="width: 84%; left: 8%; top: 37%;" data-layout-method="belowPreviousBlock">','<div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Subtitle">',"<h2>Subtitle</h2>","</div>","</div>","</section>"].join("")},{html:["<section>",'<div class="sl-block" data-block-type="text" style="width: 84%; left: 8%; top: 27%;">','<div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text">',"<h2>Title Text</h2>","</div>","</div>",'<div class="sl-block" data-block-type="text" style="width: 84%; left: 8%; top: 37%;" data-layout-method="belowPreviousBlock">','<div class="sl-block-content">',"<ul>","<li>Bullet One</li>","<li>Bullet Two</li>","<li>Bullet Three</li>","</ul>","</div>","</div>","</section>"].join("")},{html:["<section>",'<div class="sl-block" data-block-type="text" style="width: 40%; left: 5%; top: 15%; height: auto;">','<div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text" style="text-align: left;">',"<h2>Title Text</h2>","</div>","</div>",'<div class="sl-block" data-block-type="text" style="width: 40%; left: 5%; top: 30%; height: auto;">','<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin urna odio, aliquam vulputate faucibus id, elementum lobortis felis. Mauris urna dolor, placerat ac sagittis quis." style="text-align: left;">',"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin urna odio, aliquam vulputate faucibus id, elementum lobortis felis. Mauris urna dolor, placerat ac sagittis quis.</p>","</div>","</div>",'<div class="sl-block" data-block-type="text" style="width: 40%; left: 55%; top: 15%; height: auto;">','<div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text" style="text-align: left;">',"<h2>Title Text</h2>","</div>","</div>",'<div class="sl-block" data-block-type="text" style="width: 40%; left: 55%; top: 30%; height: auto;">','<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin urna odio, aliquam vulputate faucibus id, elementum lobortis felis. Mauris urna dolor, placerat ac sagittis quis." style="text-align: left;">',"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin urna odio, aliquam vulputate faucibus id, elementum lobortis felis. Mauris urna dolor, placerat ac sagittis quis.</p>","</div>","</div>","</section>"].join("")},{html:["<section>",'<div class="sl-block" data-block-type="text" style="width: 90%; left: 30px; top: 58px; height: auto;">','<div class="sl-block-content" data-placeholder-tag="h1" style="font-size: 200%; text-align: left;">',"<h1>One<br>Two<br>Three</h1>","</div>","</div>","</section>"].join("")},{html:["<section>",'<div class="sl-block" data-block-type="text" style="width: 84%; left: 8%; top: 6%;">','<div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text">',"<h2>Title Text</h2>","</div>","</div>",'<div class="sl-block" data-block-type="image" style="width: 74%; height: 68%; left: 13%; top: 22%;">','<div class="sl-block-content">','<div class="editing-ui sl-block-overlay sl-block-placeholder"></div>',"</div>","</div>","</section>"].join("")},{html:["<section>",'<div class="sl-block" data-block-type="text" style="width: 43%; left: 3%; top: 12%;">','<div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text" style="text-align: left;">',"<h2>Title Text</h2>","</div>","</div>",'<div class="sl-block" data-block-type="text" style="width: 43%; left: 3%; top: 24%;" data-layout-method="belowPreviousBlock">','<div class="sl-block-content" data-placeholder-tag="p" data-placeholder-text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi nec metus justo. Aliquam erat volutpat." style="z-index: 13; text-align: left;">',"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi nec metus justo. Aliquam erat volutpat.</p>","</div>","</div>",'<div class="sl-block" data-block-type="image" style="width: 47%; height: 90%; left: 50%; top: 5%;">','<div class="sl-block-content">','<div class="editing-ui sl-block-overlay sl-block-placeholder"></div>',"</div>","</div>","</section>"].join("")},{html:["<section>",'<div class="sl-block" data-block-type="image" style="width: 74%; height: 68%; left: 13%; top: 6%;">','<div class="sl-block-content">','<div class="editing-ui sl-block-overlay sl-block-placeholder"></div>',"</div>","</div>",'<div class="sl-block" data-block-type="text" style="width: 84%; left: 8%; top: 82%;">','<div class="sl-block-content" data-placeholder-tag="h2" data-placeholder-text="Title Text">',"<h2>Title Text</h2>","</div>","</div>","</section>"].join("")}],LAYOUT_METHODS:{belowPreviousBlock:function(t,e){var i=e.prev().get(0);i&&e.css("top",i.offsetTop+i.offsetHeight)},horizontalCenter:function(t,e){e.css("left",.5*(t.width()-e.width()))}},getNewDeckTemplate:function(){return new SL.models.Template(SL.data.templates.NEW_DECK_TEMPLATE)},getDefaultTemplates:function(){return new SL.collections.Collection(SL.data.templates.DEFAULT_TEMPLATES,SL.models.Template)},userTemplatesLoaded:!1,userTemplatesLoading:!1,userTemplatesCallbacks:[],getUserTemplates:function(t){t=t||function(){},SL.data.templates.userTemplatesLoading===!1&&SL.data.templates.userTemplatesLoaded===!1?(SL.data.templates.userTemplatesLoading=!0,SL.data.templates.userTemplatesCallbacks.push(t),$.ajax({type:"GET",url:SL.endpoints.SLIDE_TEMPLATES_LIST,context:this}).done(function(t){SL.data.templates.userTemplates=new SL.collections.Collection(t.results,SL.models.Template),SL.data.templates.userTemplatesLoaded=!0,SL.data.templates.userTemplatesLoading=!1,SL.data.templates.userTemplatesCallbacks.forEach(function(t){t.call(null,SL.data.templates.userTemplates)}),SL.data.templates.userTemplatesCallbacks.length=0}).fail(function(){SL.data.templates.userTemplatesLoading=!1,SL.notify(SL.locale.get("TEMPLATE_LOAD_ERROR"),"negative")})):SL.data.templates.userTemplatesLoading?SL.data.templates.userTemplatesCallbacks.push(t):t.call(null,SL.data.templates.userTemplates)},teamTemplatesLoaded:!1,teamTemplatesLoading:!1,teamTemplatesCallbacks:[],getTeamTemplates:function(t){SL.current_user.isEnterprise()&&(t=t||function(){},SL.data.templates.teamTemplatesLoading===!1&&SL.data.templates.teamTemplatesLoaded===!1?(SL.data.templates.teamTemplatesLoading=!0,SL.data.templates.teamTemplatesCallbacks.push(t),$.ajax({type:"GET",url:SL.endpoints.TEAM_SLIDE_TEMPLATES_LIST,context:this}).done(function(t){SL.data.templates.teamTemplates=new SL.collections.Collection(t.results,SL.models.Template),SL.data.templates.teamTemplatesLoaded=!0,SL.data.templates.teamTemplatesLoading=!1,SL.data.templates.teamTemplatesCallbacks.forEach(function(t){t.call(null,SL.data.templates.teamTemplates)}),SL.data.templates.teamTemplatesCallbacks.length=0}).fail(function(){SL.data.templates.teamTemplatesLoading=!1,SL.notify(SL.locale.get("TEMPLATE_LOAD_ERROR"),"negative")})):SL.data.templates.teamTemplatesLoading?SL.data.templates.teamTemplatesCallbacks.push(t):t.call(null,SL.data.templates.teamTemplates))},layoutTemplate:function(t,e){t.find(".sl-block").each(function(i,n){block=$(n);var s=block.attr("data-layout-method");s&&s.split(",").forEach(function(i){i=i.trim(),i.length&&"function"==typeof SL.data.templates.LAYOUT_METHODS[i]&&(e||block.removeAttr("data-layout-method"),SL.data.templates.LAYOUT_METHODS[i](t,block))}),e||/%/.test(n.style.width+n.style.height+n.style.left+n.style.top)&&block.css({left:n.offsetLeft,top:n.offsetTop,width:"auto"===n.style.width?"auto":n.offsetWidth,height:"auto"===n.style.height?"auto":n.offsetHeight})})},templatize:function(t,e){t=$(t),e=$.extend({includeNotes:!1,placeholderText:!1,zIndex:!0},e);var i=SL.editor.controllers.Serialize.getSlideAsString(t,{templatize:!0,inner:!0}),n=$("<section>"+i+"</section>");n.children().each(function(t,i){i=$(i),i.css({"min-width":"","min-height":""});var n=i.find(".sl-block-content");if(e.placeholderText&&"text"===i.attr("data-block-type")&&1===n.children().length){var s=$(n.children()[0]);s.is("h1, h2")?(s.html("Title Text"),n.attr("data-placeholder-text","Title Text")):s.is("p")&&n.attr("data-placeholder-text",s.text().trim())}e.zIndex===!1&&n.css("z-index","")});var s=["class","data-autoslide","data-auto-animate","data-auto-animate-easing","data-auto-animate-duration","data-auto-animate-unmatched","data-transition","data-transition-speed","data-background","data-background-color","data-background-image","data-background-video","data-background-video-muted","data-background-video-loop","data-background-iframe","data-background-interactive","data-background-size","data-background-position","data-background-opacity","data-background-transition"];return e.includeNotes===!0&&s.push("data-notes"),s.forEach(function(e){t.get(0).hasAttribute(e)&&n.attr(e,t.attr(e)||"")}),n.removeClass("past present future"),n.prop("outerHTML").trim()},generateFullSizeImageBlock:function(t,e,i,n,s,o){var a=Math.min(n/e,s/i),r=e*a,l=i*a,d=SL.util.deck.getSlideSize(),c=Math.round((d.width-r)/2),h=Math.round((d.height-l)/2),u=o===!0?'data-locked="true"':"";return['<div class="sl-block" data-block-type="image" style="width: '+r+"px; height: "+l+"px; left: "+c+"px; top: "+h+'px;" '+u+">",'<div class="sl-block-content">','<img src="'+t+'" style="" data-natural-width="'+e+'" data-natural-height="'+i+'"/>',"</div>","</div>"].join("")}},SL("data").tokens={get:function(t,e){e=e||{},this._addCallbacks(t,e.success,e.error),"object"==typeof this.cache[t]?this._triggerSuccessCallback(t,this.cache[t]):"loading"!==this.cache[t]&&(this.cache[t]="loading",$.ajax({type:"GET",context:this,url:SL.endpoints.ACCESS_TOKENS_LIST(t)}).done(function(e){var i=new SL.collections.Collection(e.results,SL.models.AccessToken);this.cache[t]=i,this._triggerSuccessCallback(t,i)}).fail(function(e){delete this.cache[t],this._triggerErrorCallback(t,e.status)}))},create:function(t){return new Promise(function(e,i){SL.data.tokens.get(t,{success:function(n){$.ajax({type:"POST",context:this,url:SL.endpoints.ACCESS_TOKENS_CREATE(t),data:{access_token:{name:n.getUniqueName("Link","name",!0)}}}).done(function(t){n.create(t).then(e,i)}).fail(i)}.bind(this),error:function(){console.warn("Failed to load token collection for deck "+t),i()}.bind(this)})}.bind(this))},cache:{},callbacks:{},_addCallbacks:function(t,e,i){this.callbacks[t]||(this.callbacks[t]={success:[],error:[]}),e&&this.callbacks[t].success.push(e),i&&this.callbacks[t].error.push(i)},_triggerSuccessCallback:function(t,e){var i=this.callbacks[t];if(i){for(;i.success.length;)i.success.pop().call(null,e);i.success=[],i.error=[]}},_triggerErrorCallback:function(t,e){var i=this.callbacks[t];if(i){for(;i.error.length;)i.error.pop().call(null,e);i.success=[],i.error=[]}}},SL.activity={init:function(){this.initialized||(this.initialized=!0,this.history=[Date.now()],this.listeners=[],this.bind(),setInterval(this.checkListeners.bind(this),500))},bind:function(){this.onUserInput=$.throttle(this.onUserInput.bind(this),100),document.addEventListener("mousedown",this.onUserInput),document.addEventListener("mousemove",this.onUserInput),document.addEventListener("touchstart",this.onUserInput),document.addEventListener("touchmove",this.onUserInput),document.addEventListener("keydown",this.onUserInput),window.addEventListener("scroll",this.onUserInput),window.addEventListener("mousewheel",this.onUserInput)},checkListeners:function(){this.listeners.forEach(function(t){this.hasBeenInactiveFor(t.duration)?t.active===!0&&(t.active=!1,"function"==typeof t.inactiveCallback&&t.inactiveCallback()):t.active===!1&&(t.active=!0,"function"==typeof t.activeCallback&&t.activeCallback())},this)},hasBeenInactiveFor:function(t){return Date.now()-this.history[0]>t},register:function(t,e,i){this.initialized||this.init(),this.listeners.push({active:!this.hasBeenInactiveFor(t),duration:t,activeCallback:e,inactiveCallback:i})},onUserInput:function(){this.history.unshift(Date.now()),this.history.splice(1e3)}},SL.analytics={CATEGORY_OTHER:"other",CATEGORY_EDITOR:"editor",CATEGORY_THEMING:"theming",CATEGORY_PRESENTING:"presenting",CATEGORY_COLLABORATION:"collaboration",_track:function(t,e,i){"undefined"!=typeof window.ga&&ga("send","event",t,e,i)},_trackPageView:function(t,e){e=e||document.title,"undefined"!=typeof window.ga&&ga(function(){for(var i=ga.getAll(),n=0;n<i.length;++n)i[n].send("pageview",{page:t,title:e})})},track:function(t,e){this._track(SL.analytics.CATEGORY_OTHER,t,e)},trackEditor:function(t,e){this._track(SL.analytics.CATEGORY_EDITOR,t,e)},trackTheming:function(t,e){this._track(SL.analytics.CATEGORY_THEMING,t,e)},trackPresenting:function(t,e){this._track(SL.analytics.CATEGORY_PRESENTING,t,e)},trackCollaboration:function(t,e){this._track(SL.analytics.CATEGORY_COLLABORATION,t,e)},trackCurrentSlide:function(t){if(window.Reveal){var e=Reveal.getCurrentSlide(),t=window.location.pathname+"/";if(e&&e.hasAttribute("id"))t+=e.getAttribute("id");else{var i=window.Reveal.getIndices();t+=i.h,"number"==typeof i.v&&i.v>0&&(t+="/"+i.v)}var n=$(e).find("h1, h2, h3").first().text().trim();(!n||n.length<2)&&(n="Untitled"),this._trackPageView(t,n)}}},SL.config={DEFAULT_SLIDE_WIDTH:960,DEFAULT_SLIDE_HEIGHT:700,DEFAULT_SLIDE_MARGIN:.05,DEFAULT_SLIDE_TRANSITION_DURATION:800,DEFAULT_SLIDE_IMAGE_BACKGROUND_SIZE:"cover",DEFAULT_SLIDE_IMAGE_BACKGROUND_POSITION:"50% 50%",DEFAULT_THEME_COLOR:"white-blue",DEFAULT_THEME_FONT:"montserrat",DEFAULT_THEME_TRANSITION:"slide",DEFAULT_THEME_BACKGROUND_TRANSITION:"slide",EDITOR_MIN_SCALE:.15,EDITOR_MAX_SCALE:1,EDITOR_PASTE_OFFSET:10,AUTO_ANIMATE_EASING_DEFAULT:"ease",AUTO_ANIMATE_UNMATCHED_DEFAULT:!0,AUTO_ANIMATE_DURATION_DEFAULT:1e3,AUTO_ANIMATE_DURATION_MIN:0,AUTO_ANIMATE_DURATION_MAX:1e4,AUTO_ANIMATE_DELAY_DEFAULT:0,AUTO_ANIMATE_DELAY_MIN:0,AUTO_ANIMATE_DELAY_MAX:1e4,MAX_GROUP_NESTING:6,SLIDE_SIZES:[{label:"960x700 \u2014 Default",width:960,height:700},{label:"1024x576 \u2014 16:9",width:1024,height:576},{label:"1280x720 \u2014 16:9",width:1280,height:720},{label:"960x720 \u2014 4:3",width:960,height:720},{label:"600x800 \u2014 3:4",width:600,height:800}],BLOCK_MIN_SIZE:1,AUTH_STATUS_INTERVAL:6e4,UNSAVED_CHANGES_INTERVAL:1500,AUTOSAVE_INTERVAL:4e3,DECK_SAVE_TIMEOUT:25e3,DECK_TITLE_MAXLENGTH:200,DECK_TITLE_DEFAULT:"deck",MEDIA_LABEL_MAXLENGTH:200,SPEAKER_NOTES_MAXLENGTH:1e4,EDITOR_FLOATING_ACTION_RADIUS:50,COLLABORATION_IDLE_TIMEOUT:24e4,COLLABORATION_RESET_WRITING_TIMEOUT:15e3,COLLABORATION_SEND_WRITING_INTERVAL:5e3,COLLABORATION_COMMENT_MAXLENGTH:1e3,STREAM_POINTER_UPDATE_FREQUENCY:50,STREAM_ENGINE_HOST:window.location.protocol+"//stream2.slides.com",STREAM_ENGINE_LIVE_NAMESPACE:"live",STREAM_ENGINE_EDITOR_NAMESPACE:"editor",APP_HOST:"slides.com",APP_ENV:"production",S3_HOST:"https://s3.amazonaws.com/media-p.slid.es",CDN_HOST:"https://media.slid.es",MAX_IMPORT_UPLOAD_SIZE:104857600,EXPORT_PDF_TIMEOUT:18e4,EXPORT_ZIP_TIMEOUT:18e4,EXPORT_PPT_TIMEOUT:54e4,IMAGE_UPLOAD_TIMEOUT:12e4,VIDEO_UPLOAD_TIMEOUT:6e5,VIDEO_TRANSCODE_TIMEOUT:6e5,IMPORT_SOCKET_TIMEOUT:24e4,PRESENT_CONTROLS_DEFAULT:!0,PRESENT_UPSIZING_DEFAULT:!0,PRESENT_UPSIZING_MAX_SCALE:10,KIOSK_AUTOSLIDE_DEFAULT:8e3,KIOSK_CHANGE_PING_INTERVAL:3e5,DEFAULT_EXPORT_CONTROLS:!0,DEFAULT_EXPORT_SEPARATE_FRAGMENTS:!0,DEFAULT_EDITOR_FIXED_NOTES:!1,DEFAULT_EXPORT_MARGIN:0,AUTO_SLIDE_OPTIONS:[2,4,6,8,10,15,20,30,40,60,120,180],DECK_TIME_LIMIT:[5,10,15,20,25,30,40,50,60],RESERVED_SLIDE_CLASSES:["past","present","future","disabled","overflowing","selected","focused","in-view","drag-target","has-dark-background","has-light-background"],FRAGMENT_STYLES:[{id:"",title:"Fade in"},{id:"fade-down",title:"Fade in from above"},{id:"fade-up",title:"Fade in from below"},{id:"fade-right",title:"Fade in from left"},{id:"fade-left",title:"Fade in from right"},{id:"fade-out",title:"Fade out"},{id:"semi-fade-out",title:"Fade out 50%"},{id:"current-visible",title:"Fade in then out"},{id:"fade-in-then-semi-out",title:"Fade in then obfuscate"}],THEME_COLORS:[{id:"white-blue"},{id:"sand-blue"},{id:"beige-brown"},{id:"silver-green"},{id:"silver-blue"},{id:"sky-blue"},{id:"blue-yellow"},{id:"cobalt-orange"},{id:"asphalt-orange"},{id:"forest-yellow"},{id:"mint-beige"},{id:"sea-yellow"},{id:"yellow-black"},{id:"coral-blue"},{id:"grey-blue"},{id:"black-blue"},{id:"black-mint"},{id:"black-orange"}],THEME_FONTS:[{id:"montserrat",title:"Montserrat"},{id:"league",title:"League"},{id:"opensans",title:"Open Sans"},{id:"josefine",title:"Josefine"},{id:"palatino",title:"Palatino"},{id:"news",title:"News"},{id:"helvetica",title:"Helvetica"},{id:"merriweather",title:"Merriweather"},{id:"asul",title:"Asul"},{id:"sketch",title:"Sketch"},{id:"quicksand",title:"Quicksand"},{id:"overpass",title:"Overpass v1",deprecated:!0},{id:"overpass2",title:"Overpass"}],THEME_TRANSITIONS:[{id:"slide",title:"Slide"},{id:"linear",title:"Linear",deprecated:!0},{id:"default",title:"Convex"},{id:"concave",title:"Concave"},{id:"fade",title:"Fade"},{id:"none",title:"None"},{id:"zoom",title:"Zoom"},{id:"cube",title:"Cube",deprecated:!0},{id:"page",title:"Page",deprecated:!0}],THEME_BACKGROUND_TRANSITIONS:[{id:"slide",title:"Slide"},{id:"convex",title:"Convex"},{id:"concave",title:"Concave"},{id:"fade",title:"Fade"},{id:"none",title:"None"},{id:"zoom",title:"Zoom"}],EASING_EQUATIONS:[{value:"linear",title:"Linear",path:"M0 100 L100 0"},{value:"ease",title:"Ease",path:"M0 100 C25 100 25 10  100 0"},{value:"ease-out",title:"Ease out",path:"M0 100 C0 100 58 0 100 0"},{value:"ease-in",title:"Ease in",path:"M0 100 C42 100 100 0 100 0"},{value:"cubic-bezier(0.175, 0.885, 0.320, 1.275)",title:"Back out",path:"M0 100 C17.5 12 25 -25 100 0"},{value:"cubic-bezier(0.600, -0.280, 0.735, 0.045)",title:"Back in",path:"M0 100 C40 112 73.5 95.5 100 0"},{value:"cubic-bezier(0.680, -0.550, 0.265, 1.550)",title:"Back in & out",path:"M0 100 C68 145 26.5 -45 100 0"},{value:"cubic-bezier(0.230, 1.000, 0.320, 1.000)",title:"Quint out",path:"M0 100 C23 0 32 0 100 0"},{value:"cubic-bezier(0.755, 0.050, 0.855, 0.060)",title:"Quint in",path:"M0 100 C75.5 95 85.5 94 100 0"},{value:"cubic-bezier(0.860, 0.000, 0.070, 1.000)",title:"Quint in & out",path:"M0 100 C86 100 7 0 100 0"}],BLOCKS:[{type:"text",factory:"Text",label:"Text",icon:"type"},{type:"image",factory:"Image",label:"Image",icon:"picture"},{type:"video",factory:"Video",label:"Video",icon:"video-camera"},{type:"shape",factory:"Shape",label:"Shape",icon:"shapes"},{type:"line",factory:"Line",label:"Line",icon:""},{type:"iframe",factory:"Iframe",label:"Iframe",icon:"browser"},{type:"table",factory:"Table",label:"Table",icon:"table"},{type:"code",factory:"Code",label:"Code",icon:"code"},{type:"math",factory:"Math",label:"Math",icon:"divide"},{type:"snippet",factory:"Snippet",label:"snippet",icon:"file-xml",hidden:!0},{type:"group",factory:"Group",label:"Group",icon:"",hidden:!0}],CODE_LANGUAGES:[{value:"none",title:"Automatic"},{value:"1c",title:"1C"},{value:"actionscript",title:"ActionScript"},{value:"apache",title:"Apache"},{value:"applescript",title:"AppleScript"},{value:"asciidoc",title:"AsciiDoc"},{value:"autohotkey",title:"AutoHotkey"},{value:"avrasm",title:"AVR Assembler"},{value:"axapta",title:"Axapta"},{value:"bash",title:"Bash"},{value:"clojure",title:"Clojure"},{value:"cmake",title:"CMake"},{value:"coffeescript",title:"CoffeeScript"},{value:"cpp",title:"C++"},{value:"cs",title:"C#"},{value:"css",title:"CSS",mime:"text/css"},{value:"d",title:"D"},{value:"dart",title:"Dart"},{value:"delphi",title:"Delphi"},{value:"diff",title:"Diff"},{value:"django",title:"Django "},{value:"dockerfile",title:"Dockerfile"},{value:"dos",title:"DOS"},{value:"elixir",title:"Elixir"},{value:"elm",title:"Elm"},{value:"erlang",title:"Erlang"},{value:"fix",title:"FIX"},{value:"fsharp",title:"F#"},{value:"gherkin",title:"gherkin"},{value:"glsl",title:"GLSL"},{value:"go",title:"Go"},{value:"haml",title:"Haml"},{value:"handlebars",title:"Handlebars"},{value:"haskell",title:"Haskell"},{value:"xml",title:"HTML",mime:"text/html"},{value:"http",title:"HTTP"},{value:"ini",title:"Ini file"},{value:"java",title:"Java"},{value:"javascript",title:"JavaScript",mime:"text/javascript"},{value:"json",title:"JSON",mime:"application/json"},{value:"julia",title:"Julia"},{value:"julia-repl",title:"Julia REPL"},{value:"kotlin",title:"Kotlin"},{value:"lasso",title:"Lasso"},{value:"less",title:"LESS",mime:"text/x-less"},{value:"lisp",title:"Lisp"},{value:"livecodeserver",title:"LiveCode Server"},{value:"lua",title:"Lua"},{value:"makefile",title:"Makefile"},{value:"markdown",title:"Markdown"},{value:"mathematica",title:"Mathematica"},{value:"matlab",title:"Matlab"},{value:"mel",title:"MEL"},{value:"mizar",title:"Mizar"},{value:"monkey",title:"Monkey"},{value:"nginx",title:"nginx"},{value:"objectivec",title:"Objective C"},{value:"ocaml",title:"OCaml"},{value:"oxygene",title:"Oxygene"},{value:"parser3",title:"Parser 3"},{value:"perl",title:"Perl"},{value:"php",title:"PHP"},{value:"plaintext",title:"Plaintext"},{value:"profile",title:"Profile"},{value:"python",title:"Python",mime:"text/x-python"},{value:"r",title:"R"},{value:"rib",title:"RenderMan RIB"},{value:"rsl",title:"RenderMan RSL"},{value:"ruby",title:"Ruby",mime:"text/x-ruby"},{value:"ruleslanguage",title:"Oracle Rules Language"},{value:"rust",title:"Rust"},{value:"scala",title:"Scala"},{value:"scilab",title:"Scilab"},{value:"scss",title:"SCSS",mime:"text/x-scss"},{value:"smalltalk",title:"SmallTalk"},{value:"sql",title:"SQL"},{value:"stata",title:"Stata"},{value:"stylus",title:"Stylus"},{value:"swift",title:"Swift",mime:"text/x-swift"},{value:"tex",title:"TeX",mime:"text/x-stex"},{value:"twig",title:"Twig"},{value:"typescript",title:"TypeScript",mime:"text/typescript"},{value:"vala",title:"Vala"},{value:"vbnet",title:"VB.NET"},{value:"vbscript",title:"VBScript"},{value:"vhdl",title:"VHDL"},{value:"vim",title:"vim"},{value:"xml",title:"XML"},{value:"yaml",title:"YAML"}],CODE_BASE_SIZE:16,CODE_BASE_LINE_HEIGH:1.2,DEFAULT_DECK_THUMBNAIL:"https://static.slid.es/images/default-deck-thumbnail.png",DEFAULT_USER_THUMBNAIL:"https://static.slid.es/images/default-profile-picture.png",GOOGLE_FONTS_LIST:"https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyAD1SV55vtPn4d37DWGvPg8iUKhMj2Epzo",REVEAL_NOTES_URL:"/reveal/notes.html",ASSET_URLS:{"offline-v2.css":"//assets.slid.es/assets/offline-v2-1e61d46330ad6242917f0799d322da971db0965c28518429b7874e6803cf9fbc.css","homepage-background.jpg":"//assets.slid.es/assets/homepage-background-93c7a31fa21e7312383a88abbe164ec078d1074de3a0a38d4ac34635bda214da.jpg","reveal-plugins/zoom/zoom.js":"//assets.slid.es/assets/reveal-plugins/zoom/zoom-a5d62a27f9dd7ce53da982c71e540b906097da17f6aadaf4d6532ff16c39d0c4.js","reveal-plugins/markdown/marked.js":"//assets.slid.es/reveal-plugins/markdown/marked.js","reveal-plugins/markdown/markdown.js":"//assets.slid.es/assets/reveal-plugins/markdown/markdown-2f24608fb1c8a8112bc7c1abf56f55deb367637fcedf7415e04038311d328148.js","reveal-plugins/highlight/highlight.js":"//assets.slid.es/assets/reveal-plugins/highlight/highlight-b633f6a6f8f33092c77cdeec43341175b82c93f333c1bf3d52ca8ccb5f62c727.js"}},SL.config.V1={DEFAULT_THEME_COLOR:"grey-blue",DEFAULT_THEME_FONT:"league",DEFAULT_THEME_TRANSITION:"linear",DEFAULT_THEME_BACKGROUND_TRANSITION:"fade",THEME_COLORS:[{id:"grey-blue"},{id:"black-mint"},{id:"black-orange"},{id:"forest-yellow"},{id:"lila-yellow"},{id:"asphalt-orange"},{id:"sky-blue"},{id:"beige-brown"},{id:"sand-grey"},{id:"silver-green"},{id:"silver-blue"},{id:"cobalt-orange"},{id:"white-blue"},{id:"mint-beige"},{id:"sea-yellow"},{id:"coral-blue"}],THEME_FONTS:[{id:"league",title:"League"},{id:"opensans",title:"Open Sans"},{id:"josefine",title:"Josefine"},{id:"palatino",title:"Palatino"},{id:"news",title:"News"},{id:"montserrat",title:"Montserrat"},{id:"helvetica",title:"Helvetica"},{id:"asul",title:"Asul"},{id:"merriweather",title:"Merriweather"},{id:"sketch",title:"Sketch"},{id:"quicksand",title:"Quicksand"},{id:"overpass",title:"Overpass v1",deprecated:!0},{id:"overpass2",title:"Overpass"}]},SL.deckthumbs={PREVIEW_CONTROLS_TEMPLATE:'<div class="deck-preview-controls"><button class="button preview-button black-30 icon i-visibility_on hide-in-preview" data-tooltip="Preview deck"></button><button class="button open-deck-button black-30 icon i-launch show-in-preview hide-in-fullscreen" data-tooltip="Open deck"></button><button class="button fullscreen-button black-30 icon i-fullscreen show-in-preview hide-in-fullscreen" data-tooltip="Fullscreen"></button><button class="button exit-fullscreen-button black-30 icon i-fullscreen-exit show-in-fullscreen" data-tooltip="Exit fullscreen"></button><button class="button exit-preview-button black-30 icon i-visibility_off show-in-preview hide-in-fullscreen" data-tooltip="Stop preview"></button></div>',init:function(){SL.util.device.IS_PHONE||SL.util.device.IS_TABLET||$("html").on("mouseover",".sl-deck-thumbnail[data-preview-url]:not(.has-preview-controls)",this.onPreviewableThumbHover.bind(this)).on("vclick",".sl-deck-thumbnail[data-preview-url] .preview-button",this.onPreviewClicked.bind(this)).on("vclick",".sl-deck-thumbnail[data-preview-url] .exit-preview-button",this.onPreviewClicked.bind(this)).on("vclick",".sl-deck-thumbnail[data-preview-url] .fullscreen-button",this.onPreviewFullscreenClicked.bind(this)).on("vclick",".sl-deck-thumbnail[data-preview-url] .exit-fullscreen-button",this.onPreviewFullscreenClicked.bind(this)).on("vclick",".sl-deck-thumbnail[data-preview-url] .open-deck-button",this.onOpenDeckClicked.bind(this))},create:function(t,e){var i=t.getURL();e=$.extend({nodeName:"div",context:"default",link:!0,preview:!0},e);var n="<"+e.nodeName+' class="sl-deck-thumbnail">'+(typeof e.link===!0?'<a class="deck-link" href="${DECK_URL}"></a>':'<div class="deck-link"></div>')+'<div class="deck-thumb"><img class="deck-thumb-image" src="${DECK_THUMB_URL}" loading="lazy" /></div><footer class="deck-details"><div class="top"><div class="title">${DECK_TITLE}</div></div>';"default"===e.context?n+='<div class="bottom"><a class="author" href="${USER_URL}"><span class="picture" style="background-image: url(${USER_THUMB_URL})"></span><span class="name">${USER_FULL_NAME}</span></a><div class="stats"><div>${DECK_VIEWS}<span class="icon i-eye"></span></div></div></div>':"template"===e.context?n+='<div class="bottom seamless"><div class="stats"><div>${DECK_SLIDES} slides</div></div><button class="button light-grey select-button">Select <span class="icon i-chevron-right"></span></button></div>':"template-blank"===e.context&&(n+='<div class="bottom seamless"><button class="button light-grey select-button">Select <span class="icon i-chevron-right"></span></button></div>'),n+="</footer>",n+="</"+e.nodeName+">";var s={DECK_URL:i,DECK_TITLE:t.get("title"),DECK_VIEWS:SL.util.string.viewCount(t.get("view_count")),DECK_SLIDES:t.get("slide_count"),DECK_THUMB_URL:t.get("thumbnail_url"),USER_URL:t.user.getProfileURL(),USER_FULL_NAME:t.user.getNameOrSlug(),USER_THUMB_URL:t.user.getProfilePictureURL()};for(var o in s)n=n.replace("${"+o+"}",s[o]);var a=$(n);return e.preview===!0&&a.attr("data-preview-url",i),a.attr("data-context",e.context),a},toggleDeckPreview:function(t){var e="preview"===t.attr("data-state");if(this.stopAllDeckPreviews(),!e){var i=t.attr("data-preview-url")+"/fullscreen?showNotes=false&autoSlide=0&autoPlayMedia=false&fragments=false&postMessage=true&postMessageEvents=true";t.attr("data-state","preview"),t.find(".deck-thumb").append(['<div class="deck-preview">','<div class="deck-preloader">','<div class="spinner centered" data-spinner-color="#333"></div>',"</div>",'<iframe src="'+i+'"></iframe>',"</div>"].join(""));var n=t.find(".deck-preloader"),s=t.find(".deck-preview iframe");SL.util.html.generateSpinners(),s.on("load",function(){n.remove()}),s.on("error",function(){n.remove()})}},stopAllDeckPreviews:function(){$('.sl-deck-thumbnail[data-state="preview"]').removeAttr("data-state"),$(".sl-deck-thumbnail .deck-preview iframe").off("load error"),$(".sl-deck-thumbnail .deck-preview, .deck-item .deck-preloader").remove()},onPreviewableThumbHover:function(t){$(t.target).closest(".sl-deck-thumbnail").append(SL.deckthumbs.PREVIEW_CONTROLS_TEMPLATE).addClass("has-preview-controls")},onPreviewClicked:function(t){this.toggleDeckPreview($(t.target).closest(".sl-deck-thumbnail"))},onPreviewFullscreenClicked:function(t){if(SL.helpers.Fullscreen.isActive())SL.helpers.Fullscreen.exit();else{var e=$(t.target).closest('.sl-deck-thumbnail[data-state="preview"]');e.length&&(e.toggleClass("has-deck-details",e.find(".deck-details").length>0),SL.helpers.Fullscreen.enter(e.get(0)))}},onOpenDeckClicked:function(t){var e=$(t.target).closest(".sl-deck-thumbnail"),i=e.find(".deck-preview iframe").get(0),n=e.attr("data-preview-url");i?(window.addEventListener("message",function(t){var e=JSON.parse(t.data);"reveal"===e.namespace&&"callback"===e.eventName&&"getIndices"===e.method&&(window.location=n+"#/"+e.result.h+"/"+e.result.v)}),i.contentWindow.postMessage(JSON.stringify({method:"getIndices"}),"*")):window.location=n}},SL.draganddrop={init:function(){this.listeners=new SL.collections.Collection,this.onDragStart=this.onDragStart.bind(this),this.onDragOver=this.onDragOver.bind(this),this.onDragOut=this.onDragOut.bind(this),this.onDrop=this.onDrop.bind(this),this.isListening=!1,this.isInternalDrag=!1},subscribe:function(t){this.listeners.push(t),this.bind()},unsubscribe:function(t){this.listeners.remove(t),this.listeners.isEmpty()&&this.unbind()},dispatch:function(t,e){var i=this.listeners.last();i&&i[t](e)},bind:function(){this.isListening===!1&&(this.isListening=!0,$(document.documentElement).on("dragstart",this.onDragStart).on("dragover dragenter",this.onDragOver).on("dragleave",this.onDragOut).on("drop",this.onDrop))},unbind:function(){this.isListening===!0&&(this.isListening=!1,$(document.documentElement).off("dragstart",this.onDragStart).off("dragover dragenter",this.onDragOver).off("dragleave",this.onDragOut).off("drop",this.onDrop))},onDragStart:function(t){t.preventDefault(),this.isInternalDrag=!0;
},onDragOver:function(t){this.isInternalDrag||(t.preventDefault(),this.dispatch("onDragOver",t))},onDragOut:function(t){this.isInternalDrag||(t.preventDefault(),this.dispatch("onDragOut",t))},onDrop:function(t){if(!this.isInternalDrag)return t.stopPropagation(),t.preventDefault(),this.isInternalDrag=!1,this.dispatch("onDrop",t),!1}},SL.endpoints={SEARCH:"/api/v1/search.json",SEARCH_TEAM:"/api/v1/team/search.json",SEARCH_MEDIA:"/api/v1/media/search.json",DECK_LIST:function(){return"/api/v1/decks.json"},GET_DECK:function(t){return"/api/v1/decks/"+t+".json"},CREATE_DECK:function(){return"/api/v1/decks.json"},UPDATE_DECK:function(t){return"/api/v1/decks/"+t+".json"},PUBLISH_DECK:function(t){return"/api/v1/decks/"+t+"/publish.json"},MAKE_DECK_COLLABORATIVE:function(t){return"/api/v1/decks/"+t+"/make_collaborative.json"},GET_DECK_JSON:function(t,e){return"/"+t+"/"+e+".json"},GET_DECK_DATA:function(t){return"/api/v1/decks/"+t+"/data.json"},GET_DECK_UPDATED_AT:function(t){return"/api/v1/decks/"+t+"/updated_at.json"},GET_DECKS_HTML:function(t){return"/"+t+"/decks.html"},GET_DECKS_TRASHED_HTML:function(t){return"/"+t+"/decks_trashed.html"},TRASH_DECK:function(t){return"/api/v1/decks/"+t+"/trash.json"},RECOVER_DECK:function(t){return"/api/v1/decks/"+t+"/recover.json"},DESTROY_DECK:function(t){return"/api/v1/decks/"+t+".json"},GET_DECK_VERSIONS:function(t){return"/api/v1/decks/"+t+"/revisions.json"},PREVIEW_DECK_VERSION:function(t,e,i){return"/"+t+"/"+e+"/preview?revision="+i},RESTORE_DECK_VERSION:function(t,e){return"/api/v1/decks/"+t+"/revisions/"+e+"/restore.json"},EXPORT_DECK:function(t,e){return"/"+t+"/"+e+"/export"},THUMBNAIL_DECK:function(t){return"/api/v1/decks/"+t+"/thumbnails.json"},FORK_DECK:function(t){return"/api/v1/decks/"+t+"/fork.json"},SHARE_DECK_VIA_EMAIL:function(t){return"/api/v1/decks/"+t+"/deck_shares.json"},DECK_STREAM:function(t){return"/api/v1/decks/"+t+"/stream.json"},SMS_DECK:function(t){return"/api/v1/decks/"+t+"/sms.json"},KUDO_DECK:function(t){return"/api/v1/decks/"+t+"/kudos/kudo.json"},UNKUDO_DECK:function(t){return"/api/v1/decks/"+t+"/kudos/unkudo.json"},EXPORT_START:function(t){return"/api/v1/decks/"+t+"/exports.json"},EXPORT_LIST:function(t){return"/api/v1/decks/"+t+"/exports.json"},EXPORT_STATUS:function(t,e){return"/api/v1/decks/"+t+"/exports/"+e+".json"},FILE_IMPORT_NEW:"/api/v1/imports.json",FILE_IMPORT_UPLOADED:function(t){return"/api/v1/imports/"+t+".json"},DROPBOX_CONNECT:function(){return window.location.protocol+"//"+SL.config.APP_HOST+"/settings/dropbox/authorize"},DROPBOX_DISCONNECT:function(){return"https://www.dropbox.com/account/connected_apps"},DROPBOX_SYNC_DECK:function(t){return"/api/v1/decks/"+t+"/export.json"},UPDATE_TEAM:"/api/v1/team.json",LOOKUP_TEAM:"/api/v1/team/lookup.json",REMOVE_TEAM_LOGO:"/api/v1/team/remove_logo.json",TEAM_MEMBER_SEARCH:"/api/v1/team/users/search.json",TEAM_DECKS_LIST:"/api/v1/team/decks.json",TEAM_MEMBERS_LIST:"/api/v1/team/users.json",TEAM_MEMBER_CREATE:"/api/v1/team/users.json",TEAM_MEMBER_UPDATE:function(t){return"/api/v1/team/users/"+t+".json"},TEAM_MEMBER_DELETE:function(t){return"/api/v1/team/users/"+t+".json"},TEAM_MEMBER_REACTIVATE:function(t){return"/api/v1/team/users/"+t+"/reactivate.json"},TEAM_MEMBER_DEACTIVATE:function(t){return"/api/v1/team/users/"+t+"/deactivate.json"},TEAM_INVITATIONS_LIST:"/api/v1/team/invitations.json",TEAM_INVITATIONS_CREATE:"/api/v1/team/invitations.json",TEAM_INVITATIONS_DELETE:function(t){return"/api/v1/team/invitations/"+t+".json"},TEAM_INVITATIONS_RESEND:function(t){return"/api/v1/team/invitations/"+t+"/resend.json"},THEMES_LIST:"/api/v1/themes.json",THEMES_CREATE:"/api/v1/themes.json",THEMES_READ:function(t){return"/api/v1/themes/"+t+".json"},THEMES_UPDATE:function(t){return"/api/v1/themes/"+t+".json"},THEMES_DELETE:function(t){return"/api/v1/themes/"+t+".json"},DECK_THEME:function(t){return"/api/v1/decks/"+t+"/theme.json"},THEME_ADD_SLIDE_TEMPLATE:function(t){return"/api/v1/themes/"+t+"/add_slide_template.json"},THEME_REMOVE_SLIDE_TEMPLATE:function(t){return"/api/v1/themes/"+t+"/remove_slide_template.json"},ACCESS_TOKENS_LIST:function(t){return"/api/v1/decks/"+t+"/access_tokens.json"},ACCESS_TOKENS_CREATE:function(t){return"/api/v1/decks/"+t+"/access_tokens.json"},ACCESS_TOKENS_UPDATE:function(t,e){return"/api/v1/decks/"+t+"/access_tokens/"+e+".json"},ACCESS_TOKENS_DELETE:function(t,e){return"/api/v1/decks/"+t+"/access_tokens/"+e+".json"},ACCESS_TOKENS_PASSWORD_AUTH:function(t){return"/access_tokens/"+t},SLIDE_TEMPLATES_LIST:"/api/v1/slide_templates.json",SLIDE_TEMPLATES_CREATE:"/api/v1/slide_templates.json",SLIDE_TEMPLATES_UPDATE:function(t){return"/api/v1/slide_templates/"+t+".json"},SLIDE_TEMPLATES_DELETE:function(t){return"/api/v1/slide_templates/"+t+".json"},TEAM_SLIDE_TEMPLATES_LIST:"/api/v1/team/slide_templates.json",TEAM_SLIDE_TEMPLATES_CREATE:"/api/v1/team/slide_templates.json",TEAM_SLIDE_TEMPLATES_UPDATE:function(t){return"/api/v1/team/slide_templates/"+t+".json"},TEAM_SLIDE_TEMPLATES_DELETE:function(t){return"/api/v1/team/slide_templates/"+t+".json"},DECK_TEMPLATES_LIST:function(){return"/api/v1/deck_templates.json"},GET_USER:function(t){return"/api/v1/users/"+t+".json"},LOOKUP_USER:"/api/v1/users/lookup.json",SERVICES_USER:"/api/v1/users/services.json",REMOVE_USER_AVATAR:"/api/v1/users/remove_avatar.json",UPDATE_USER:"/users.json",GET_USER_SETTINGS:"/api/v1/user_settings.json",UPDATE_USER_SETTINGS:"/api/v1/user_settings.json",SUBSCRIPTIONS:"/subscriptions",ACCOUNT_DETAILS:"/account/details.json",SUBSCRIPTION_DETAILS:"/account/subscription.json",SUBSCRIPTIONS_PRINT_RECEIPT:function(t){return"/account/receipts/"+t},SUBSCRIPTIONS_PRINT_INVOICE:function(t){return"/account/invoices/"+t},SUBSCRIPTIONS_REACTIVATE:"/subscriptions/reactivate",TEAMS_CREATE:"/teams.json",TEAMS_REACTIVATE:"/subscriptions/reactivate.json",CHECK_STATUS:"/api/v1/status.json",CHECK_URL:"/api/v1/urls",MEDIA_LIST:"/api/v1/media.json",MEDIA_CREATE:"/api/v1/media.json",MEDIA_READ:function(t){return"/api/v1/media/"+t+".json"},MEDIA_UPDATE:function(t){return"/api/v1/media/"+t+".json"},MEDIA_DELETE:function(t){return"/api/v1/media/"+t+".json"},MEDIA_USAGE:"/api/v1/media/usage.json",TAG_LIST:function(t){return"/api/v1/tags.json?tag_type="+t},TAG_CREATE:"/api/v1/tags.json",TAG_UPDATE:function(t){return"/api/v1/tags/"+t+".json"},TAG_DELETE:function(t){return"/api/v1/tags/"+t+".json"},TAG_ADD_MEDIA:function(t){return"/api/v1/tags/"+t+"/add_media.json"},TAG_REMOVE_MEDIA:function(t){return"/api/v1/tags/"+t+"/remove_media.json"},TAG_ADD_DECK:function(t){return"/api/v1/tags/"+t+"/add_decks.json"},TAG_REMOVE_DECK:function(t){return"/api/v1/tags/"+t+"/remove_decks.json"},TEAM_MEDIA_LIST:"/api/v1/team/media.json",TEAM_MEDIA_CREATE:"/api/v1/team/media.json",TEAM_MEDIA_READ:function(t){return"/api/v1/team/media/"+t+".json"},TEAM_MEDIA_UPDATE:function(t){return"/api/v1/team/media/"+t+".json"},TEAM_MEDIA_DELETE:function(t){return"/api/v1/team/media/"+t+".json"},TEAM_MEDIA_TAG_LIST:"/api/v1/team/tags.json",TEAM_MEDIA_TAG_CREATE:"/api/v1/team/tags.json",TEAM_MEDIA_TAG_UPDATE:function(t){return"/api/v1/team/tags/"+t+".json"},TEAM_MEDIA_TAG_DELETE:function(t){return"/api/v1/team/tags/"+t+".json"},TEAM_MEDIA_TAG_ADD_MEDIA:function(t){return"/api/v1/team/tags/"+t+"/add_media.json"},TEAM_MEDIA_TAG_REMOVE_MEDIA:function(t){return"/api/v1/team/tags/"+t+"/remove_media.json"},DECKUSER_LIST:function(t){return"/api/v1/decks/"+t+"/users.json"},DECKUSER_READ:function(t,e){return"/api/v1/decks/"+t+"/users/"+e+".json"},DECKUSER_CREATE:function(t){return"/api/v1/decks/"+t+"/users/invite.json"},DECKUSER_UPDATE:function(t,e){return"/api/v1/decks/"+t+"/users/"+e+".json"},DECKUSER_DELETE:function(t,e){return"/api/v1/decks/"+t+"/users/"+e+".json"},DECKUSER_BECOME_EDITOR:function(t,e){return"/api/v1/decks/"+t+"/users/"+e+"/become_editor.json"},DECKUSER_UPDATE_LAST_SEEN_AT:function(t){return"/api/v1/decks/"+t+"/users/update_last_seen_at.json"},COMMENTS_LIST:function(t,e){return"/api/v1/decks/"+t+"/comments.json"+(e?"?slide_hash="+e:"")},COMMENTS_CREATE:function(t){return"/api/v1/decks/"+t+"/comments.json"},COMMENTS_UPDATE:function(t,e){return"/api/v1/decks/"+t+"/comments/"+e+".json"},COMMENTS_DELETE:function(t,e){return"/api/v1/decks/"+t+"/comments/"+e+".json"}},SL.fonts={INIT_TIMEOUT:5e3,FONTS_URL:SLConfig.fonts_url||"https://static.slid.es/fonts/",FAMILIES:{montserrat:{id:"montserrat",name:"Montserrat",path:"montserrat/montserrat.css"},opensans:{id:"opensans",name:"Open Sans",path:"opensans/opensans.css"},lato:{id:"lato",name:"Lato",path:"lato/lato.css"},asul:{id:"asul",name:"Asul",path:"asul/asul.css"},josefinsans:{id:"josefinsans",name:"Josefin Sans",path:"josefinsans/josefinsans.css"},league:{id:"league",name:"League Gothic",path:"league/league_gothic.css"},merriweathersans:{id:"merriweathersans",name:"Merriweather Sans",path:"merriweathersans/merriweathersans.css"},overpass:{id:"overpass",name:"Overpass",path:"overpass/overpass.css"},overpass2:{id:"overpass2",name:"Overpass 2",path:"overpass2/overpass2.css"},quicksand:{id:"quicksand",name:"Quicksand",path:"quicksand/quicksand.css"},cabinsketch:{id:"cabinsketch",name:"Cabin Sketch",path:"cabinsketch/cabinsketch.css"},newscycle:{id:"newscycle",name:"News Cycle",path:"newscycle/newscycle.css"},oxygen:{id:"oxygen",name:"Oxygen",path:"oxygen/oxygen.css"}},PACKAGES:{asul:["asul"],helvetica:[],josefine:["josefinsans","lato"],league:["league","lato"],merriweather:["merriweathersans","oxygen"],news:["newscycle","lato"],montserrat:["montserrat","opensans"],opensans:["opensans"],overpass:["overpass"],overpass2:["overpass2"],palatino:[],quicksand:["quicksand","opensans"],sketch:["cabinsketch","oxygen"]},init:function(){if(this._isReady=!1,this.ready=new signals.Signal,this.loaded=new signals.Signal,this.fontactive=new signals.Signal,this.fontinactive=new signals.Signal,this.debugMode=!!/debug/gi.test(location.search),[].slice.call(document.querySelectorAll("link[data-application-font]")).forEach(function(t){var e=t.getAttribute("data-application-font");SL.fonts.FAMILIES[e]&&(SL.fonts.FAMILIES[e].loaded=!0)}),SLConfig&&SLConfig.deck){var t=SL.config?SL.config.DEFAULT_THEME_FONT:"montserrat",e=this.loadDeckFont([SLConfig.deck.theme_font||t],{active:this.onInitialFontsActive.bind(this),inactive:this.onInitialFontsInactive.bind(this)});e?this.initTimeout=setTimeout(function(){this.debugMode&&console.log("SL.fonts","timed out"),this.finishLoading()}.bind(this),SL.fonts.INIT_TIMEOUT):this.finishLoading()}else this.finishLoading()},load:function(t,e){var i={classes:!1,fontactive:this.onFontActive.bind(this),fontinactive:this.onFontInactive.bind(this),custom:{families:[],urls:[]}};for(var n in e)i[n]=e[n];SLConfig&&SLConfig.deck&&(SLConfig.deck.font_typekit&&(i.typekit={id:SLConfig.deck.font_typekit}),SLConfig.deck.font_google&&(i.google=i.google||{families:[]},i.google.families=i.google.families.concat(SL.fonts.parseGoogleFontFamilies(SLConfig.deck.font_google)))),SLConfig&&SLConfig.theme&&(SLConfig.theme.font_typekit&&(i.typekit={id:SLConfig.theme.font_typekit}),SLConfig.theme.font_google&&(i.google=i.google||{families:[]},i.google.families=i.google.families.concat(SL.fonts.parseGoogleFontFamilies(SLConfig.theme.font_google))));var s=[];return i.google&&i.google.families&&(s=i.google.families.map(function(t){return t.split(":")[0]})),t.forEach(function(t){var e=SL.fonts.FAMILIES[t];e?e.loaded||s.indexOf(e.name)!==-1?"function"==typeof i.fontactive&&i.fontactive(e.name):(e.loaded=!0,i.custom.families.push(e.name),i.custom.urls.push(SL.fonts.FONTS_URL+e.path)):console.warn('Could not find font family with id "'+t+'"')}),this.debugMode&&console.log("SL.fonts.load",i.custom.families),!!(i.custom.families.length||i.typekit||i.google)&&(WebFont.load(i),!0)},loadAll:function(t){var e=[];for(var i in SL.fonts.FAMILIES)e.push(i);this.load(e,t)},loadDeckFont:function(t,e){var i=SL.fonts.PACKAGES[t];return i?SL.fonts.load(i,e):SL.fonts.load([],e)},loadGoogleFont:function(t){WebFont.load({google:{families:SL.fonts.parseGoogleFontFamilies(t)}})},loadTypekitFont:function(t){WebFont.load({typekit:{id:t}})},parseGoogleFontFamilies:function(t){return t=(t||"").trim().split(", "),t=t.map(function(t){return t.trim().replace(/(^,)|(,$)/gi,"")}),t=t.filter(function(t){return"string"==typeof t&&t.length>0})},unload:function(t){t.forEach(function(t){var e=SL.fonts.FAMILIES[t];e&&(e.loaded=!1,[].slice.call(document.querySelectorAll('link[href="'+SL.fonts.FONTS_URL+e.path+'"]')).forEach(function(t){t.parentNode.removeChild(t)}))})},finishLoading:function(){clearTimeout(this.initTimeout),document.documentElement.classList.add("fonts-are-ready"),this._isReady===!1&&(this._isReady=!0,this.ready.dispatch()),this.loaded.dispatch()},getPackageIDs:function(){return Object.keys(SL.fonts.PACKAGES)},getFamilyByName:function(t){for(var e in SL.fonts.FAMILIES){var i=SL.fonts.FAMILIES[e];if(t===i.name)return i}},isPackageLoaded:function(t){var e=SL.fonts.PACKAGES[t];return!e||(0===e.length||e.every(function(t){var e=SL.fonts.FAMILIES[t];return e.active||e.inactive}))},isReady:function(){return this._isReady},onFontActive:function(t){var e=SL.fonts.getFamilyByName(t);e&&(e.active=!0),this.fontactive.dispatch(e)},onFontInactive:function(t){var e=SL.fonts.getFamilyByName(t);e&&(e.inactive=!0),this.fontinactive.dispatch(e)},onInitialFontsActive:function(){this.finishLoading()},onInitialFontsInactive:function(){this.finishLoading()}},SL.keyboard={init:function(){this.keyupConsumers=new SL.collections.Collection,this.keydownConsumers=new SL.collections.Collection,$(document).on("keydown",this.onDocumentKeyDown.bind(this)),$(document).on("keyup",this.onDocumentKeyUp.bind(this))},keydown:function(t){this.keydownConsumers.push(t)},keyup:function(t){this.keyupConsumers.push(t)},release:function(t){this.keydownConsumers.remove(t),this.keyupConsumers.remove(t)},onDocumentKeyDown:function(t){for(var e,i=this.keydownConsumers.size(),n=!1;e=this.keydownConsumers.at(--i);)if(!e(t)){n=!0;break}if(n)return t.preventDefault(),t.stopImmediatePropagation(),!1},onDocumentKeyUp:function(t){for(var e,i=this.keyupConsumers.size(),n=!1;e=this.keyupConsumers.at(--i);)if(!e(t)){n=!0;break}if(n)return t.preventDefault(),t.stopImmediatePropagation(),!1},getEditorShortcut:function(t){this.editorShortcuts||(this.editorShortcuts={EDITOR_PREVIEW:{label:"Preview",shortcut:SL.util.getKeyboardShortcutName("F",{meta:!0})},EDITOR_PRESENT:{label:"Present",shortcut:SL.util.getKeyboardShortcutName("E",{meta:!0})},EDITOR_UNDO:{label:"Undo",shortcut:SL.util.getKeyboardShortcutName("Z",{meta:!0})},COPY:{label:"Copy",shortcut:SL.util.getKeyboardShortcutName("C",{meta:!0})},PASTE:{label:"Paste",shortcut:SL.util.getKeyboardShortcutName("L",{meta:!0,shift:!0})},DELETE:{label:"Delete",shortcut:SL.util.getKeyboardShortcutName("&#9003")},DUPLICATE:{label:"Duplicate",shortcut:SL.util.getKeyboardShortcutName("D",{meta:!0})},LOCK:{label:"Lock",shortcut:SL.util.getKeyboardShortcutName("L",{meta:!0,shift:!0})},GROUP:{label:"Group",shortcut:SL.util.getKeyboardShortcutName("G",{meta:!0})},UNGROUP:{label:"Ungroup",shortcut:SL.util.getKeyboardShortcutName("G",{meta:!0,shift:!0})},BRING_TO_FRONT:{label:"Bring to front",shortcut:SL.util.getKeyboardShortcutName("]",{meta:!0})},SEND_TO_BACK:{label:"Send to back",shortcut:SL.util.getKeyboardShortcutName("[",{meta:!0})},MOVE_CENTER:{label:"Move to center",shortcut:SL.util.getKeyboardShortcutName("C",{alt:!0})},MOVE_TOP:{label:"Move to top edge",shortcut:SL.util.getKeyboardShortcutName("&#8593",{alt:!0})},MOVE_RIGHT:{label:"Move to right edge",shortcut:SL.util.getKeyboardShortcutName("&#8594",{alt:!0})},MOVE_BOTTOM:{label:"Move to bottom edge",shortcut:SL.util.getKeyboardShortcutName("&#8595",{alt:!0})},MOVE_LEFT:{label:"Move to left edge",shortcut:SL.util.getKeyboardShortcutName("&#8592",{alt:!0})},REMOVE_SLIDE:{label:"Remove slide",shortcut:SL.util.getKeyboardShortcutName("&#9003",{meta:!0})},SHOW_SLIDE:{label:"Show slide",shortcut:SL.util.getKeyboardShortcutName("H",{meta:!0})},HIDE_SLIDE:{label:"Hide slide",shortcut:SL.util.getKeyboardShortcutName("H",{meta:!0})},SLIDE_SETTINGS:{label:"Slide settings",shortcut:SL.util.getKeyboardShortcutName("S",{shift:!0,alt:!0})},SLIDE_EDIT_HTML:{label:"Edit HTML",shortcut:SL.util.getKeyboardShortcutName("H",{shift:!0,alt:!0})},FRAGMENT_MODE:{label:"Create fragments",shortcut:SL.util.getKeyboardShortcutName("F",{shift:!0,alt:!0})},SPEAKER_NOTES:{label:"Speaker Notes",shortcut:SL.util.getKeyboardShortcutName("N",{shift:!0,alt:!0})},AUTO_ANIMATE:{label:"Auto-Animate",shortcut:SL.util.getKeyboardShortcutName("A",{shift:!0,alt:!0})}});var e=this.editorShortcuts[t];return"string"!=typeof e.tooltip&&(e.tooltip=e.label+' <span class="keyboard-shortcut">'+e.shortcut+"</span>"),e}},SL.locale={GENERIC_ERROR:["Oops, something went wrong","We ran into an unexpected error","Something's wong, can you try that again?"],WARN_UNSAVED_CHANGES:"You have unsaved changes, save first?",CLOSE:"Close",PREVIOUS:"Previous",NEXT:"Next",DECK_SAVE_SUCCESS:"Saved successfully",DECK_SAVE_ERROR:"Failed to save",NEW_SLIDE_TITLE:"Title",LEAVE_UNSAVED_DECK:"You will lose your unsaved changes.",LEAVE_UNSAVED_THEME:"You will lose your unsaved changes.",DOWNGRADE_TO_FREE_CONFIRM:"You'll remain upgraded for the time you have already paid for.",DOWNGRADE_TO_FREE_SUCCESS:"Subscription canceled",DECK_RESTORE_CONFIRM:"Are you sure you want to revert the deck to this version from {#time}?",SLIDE_RESTORE_CONFIRM:"Are you sure you want to roll back to this version?",SLIDE_DUPLICATED:"Duplicated slide",SLIDE_VISIBILITY_ON:"Slide is now visible",SLIDE_VISIBILITY_OFF:"Slide is now hidden",DECK_TRASH_CONFIRM:'Are you sure you want to delete "{#title}"?',DECK_TRASH_CONFIRM_MULTIPLE:"Are you sure you want to delete these decks?",DECK_TRASH_SUCCESS:"Moved to trash",DECK_TRASH_ERROR:"Failed to delete",DECK_DESTROY_CONFIRM:'Are you sure you want to permanently delete "{#title}"?',DECK_DESTROY_SUCCESS:"Deck deleted",DECK_DESTROY_ERROR:"Failed to delete",DECK_RECOVER_CONFIRM:'Are you sure you want to recover "{#title}"?',DECK_RECOVER_SUCCESS:"Deck recovered",DECK_RECOVER_ERROR:"Failed to recover",DECK_VISIBILITY_CHANGE_SELF:'<div><span class="icon i-lock-stroke"></span></div><h3>Private</h3><p>Only visible to you</p>',DECK_VISIBILITY_CHANGE_TEAM:'<div><span class="icon i-users"></span></div><h3>Internal</h3><p>Visible to your team</p>',DECK_VISIBILITY_CHANGE_ALL:'<div><span class="icon i-globe"></span></div><h3>Public</h3><p>Visible to the world</p>',DECK_VISIBILITY_SHARE_LINK:'<div><span class="icon i-link"></span></div><h3>Create link</h3><p>For external sharing</p>',DECK_VISIBILITY_CHANGED_SELF:"Your deck is now private",DECK_VISIBILITY_CHANGED_TEAM:"Your deck is now internal",DECK_VISIBILITY_CHANGED_ALL:"Your deck is now public",DECK_VISIBILITY_CHANGED_ERROR:"Failed to change visibility",DECK_EDIT_INVALID_TITLE:"Please enter a valid title",DECK_EDIT_INVALID_SLUG:"Please enter a valid URL",DECK_DELETE_SLIDE_CONFIRM:"Are you sure you want to remove this slide?",DECK_IMPORT_HTML_CONFIRM:"All existing content will be replaced, continue?",EXPORT_PDF_BUTTON:"Download PDF",EXPORT_PDF_BUTTON_WORKING:"Exporting...",EXPORT_PDF_ERROR:"An error occured while exporting your PDF.",EXPORT_PPT_BUTTON:"Download PPTX",EXPORT_PPT_BUTTON_WORKING:"Exporting...",EXPORT_PPT_ERROR:"An error occured while exporting to PowerPoint.",EXPORT_ZIP_BUTTON:"Download ZIP",EXPORT_ZIP_BUTTON_WORKING:"Exporting...",EXPORT_ZIP_ERROR:"An error occured while exporting your ZIP.",FORM_ERROR_REQUIRED:"Required",FORM_ERROR_USERNAME_TAKEN:["That one's already taken :(","Sorry, that's taken too"],FORM_ERROR_ORGANIZATION_SLUG_TAKEN:["That one's already taken :(","Sorry, that's taken too"],BILLING_DETAILS_ERROR:"An error occured while fetching your billing details, please try again.",BILLING_DETAILS_NOHISTORY:"You haven't made any payments yet.",THEME_CREATE:"New theme",THEME_CREATE_ERROR:"Failed to create theme",THEME_SAVE_SUCCESS:"Theme saved",THEME_SAVE_ERROR:"Failed to save theme",THEME_REMOVE_CONFIRM:"Are you sure you want to delete this theme?",THEME_REMOVE_SUCCESS:"Theme removed successfully",THEME_REMOVE_ERROR:"Failed to remove theme",THEME_LIST_LOAD_ERROR:"Failed to load themes",THEME_LIST_EMPTY:"Once you have created one or more themes they'll be listed here. Click the New Theme button to get started with your first theme.",THEME_DEFAULT_SAVE_SUCCESS:"Default theme was changed",THEME_DEFAULT_SAVE_ERROR:"Failed to change default theme",THEME_DELETE_TOOLTIP:"Delete",THEME_EDIT_TOOLTIP:"Edit",THEME_MAKE_DEFAULT_TOOLTIP:"Make this the default theme",THEME_IS_DEFAULT_TOOLTIP:"This is the default theme",THEME_SNIPPET_DELETE_CONFIRM:"Are you sure you want to delete this snippet?",TEMPLATE_LOAD_ERROR:"Failed to load slide templates",TEMPLATE_CREATE_SUCCESS:"Template saved!",TEMPLATE_CREATE_ERROR:"Failed to save template",TEMPLATE_DELETE_CONFIRM:"Are you sure you want to delete this template?",TEMPLATE_SAVE_SLIDE_LABEL:"Save current slide",TEMPLATE_PERSONAL_TEMPLATES_LABEL:"My Saved Slides",TEMPLATE_PERSONAL_DECKS_LABEL:"My Decks",TEMPLATE_TEAM_TEMPLATES_LABEL:"Slide Templates",TEMPLATE_TEAM_DECKS_LABEL:"Internal Decks",SEARCH_PAGINATION_PAGE:"Page",SEARCH_NO_RESULTS_FOR:'No results for "{#term}"',SEARCH_SERVER_ERROR:"Failed to fetch search results",SEARCH_NO_TERM_ERROR:"Please enter a search term",TAG_DELETE_CONFIRM:"Are you sure you want to delete this tag?",TAG_DELETE_SUCCESS:"Tag deleted",TAG_DELETE_ERROR:"Failed to delete",TAG_DEFAULT_CONFIRM:"This tag will be selected by default when visiting your profile page. Are you sure you want to continue?",COLLABORATOR_REMOVE_CONFIRM:"Are you sure you want to remove this user?",ARRANGE_CANT_DELETE_ALL_SLIDES:"You can't delete all slides in the deck.",BLOCKED_BY_X_FRAME_OPTIONS:"Embedding of this URL is prevented by the site owner (X-Frame-Options).",FRAGMENT_TOOLTIP_STYLE:"Select the type of animation to use for this fragment.",FRAGMENT_TOOLTIP_INDEX:"The order in which the fragment will appear, relative to other fragments.",FRAGMENT_TOOLTIP_REMOVE:"Remove the fragment and return this element to its original state.",SET_NATURAL_IMAGE_SIZE:"Set original image size ({#width}x{#height})",NOTES_PUBLIC:'Your notes are <a href="http://help.slides.com/knowledgebase/articles/729753" target="_blank">publicly visible</a>.',NOTES_PRIVATE:'Your notes are private, learn how to <a href="http://help.slides.com/knowledgebase/articles/729753" target="_blank">share them</a>.',OPEN_DECK_IN:"Open deck...",counter:{},get:function(t,e){var i=SL.locale[t];if("object"==typeof i&&i.length&&("number"==typeof this.counter[t]?this.counter[t]=(this.counter[t]+1)%i.length:this.counter[t]=0,i=i[this.counter[t]]),"object"==typeof e)for(var n in e)i=i.replace("{#"+n+"}",e[n]);return"string"==typeof i?i:""}},SL.pointer={down:!1,downTimeout:-1,init:function(){$(document).on("mousedown",this.onMouseDown.bind(this)),$(document).on("mouseleave",this.onMouseLeave.bind(this)),$(document).on("mouseup",this.onMouseUp.bind(this))},isDown:function(){return this.down},setActiveCursor:function(t){$("html").attr("data-active-cursor",t)},clearActiveCursor:function(){$("html").removeAttr("data-active-cursor")},onMouseDown:function(){clearTimeout(this.downTimeout),this.down=!0,this.downTimeout=setTimeout(function(){this.down=!1}.bind(this),3e4)},onMouseLeave:function(){clearTimeout(this.downTimeout),this.down=!1},onMouseUp:function(){clearTimeout(this.downTimeout),this.down=!1}},SL.promotions={STORAGE_KEY:"slides-last-promotion-id",MESSAGE_ID:4,MESSAGE_CONDITION:function(){return SL.current_user&&SL.current_user.isFree()&&(!$("html").is(".decks")||$("html").is(".decks.edit"))},MESSAGE_EXPIRY:"Jan 28 2020 23:00:00 PST",init:function(){this.showMessage()},showMessage:function(){if(this.hasMessage()&&!this.hasExpired()&&SL.util.user.isLoggedIn()&&Modernizr.localstorage&&("function"!=typeof this.MESSAGE_CONDITION||this.MESSAGE_CONDITION())){var t=parseInt(localStorage.getItem(this.STORAGE_KEY),10)||0;if(t<this.MESSAGE_ID){var e=SL.notify(this.MESSAGE_TEXT,{optional:!1,buttons:this.MESSAGE_BUTTONS,type:"white-shadow"});e.destroyed.add(this.hideMessage.bind(this))}}},hideMessage:function(){Modernizr.localstorage&&localStorage.setItem(this.STORAGE_KEY,this.MESSAGE_ID)},hasMessage:function(){return!!this.MESSAGE_TEXT},hasExpired:function(){return!!this.MESSAGE_EXPIRY&&moment().diff(moment(this.MESSAGE_EXPIRY))>0}},SL.routes={PRICING:"/pricing",CHANGELOG:"/changelog",SIGN_IN:"/users/sign_in",SIGN_OUT:"/users/sign_out",NEW_TEAM:"/teams/new",BRAND_KIT:"/about#brand",SECURITY_COOKIES:"/security/cookies",SUBSCRIPTIONS_NEW:"/account/upgrade",SUBSCRIPTIONS_EDIT_CARD:"/account/update_billing",SUBSCRIPTIONS_EDIT_PERIOD:"/account/update_billing_period",USER:function(t){return"/"+t},USER_EDIT:"/users/edit",DECK:function(t,e){return"/"+t+"/"+e},DECK_NEW:function(t){return"/"+t+"/new"},DECK_EDIT:function(t,e){return"/"+t+"/"+e+"/edit"},DECK_REVIEW:function(t,e){return"/"+t+"/"+e+"/review"},DECK_EMBED:function(t,e){return"/"+t+"/"+e+"/embed"},DECK_LIVE:function(t,e){return"/"+t+"/"+e+"/live"},DECK_KIOSK:function(t,e){return"/"+t+"/"+e+"/kiosk"},DECK_FULLSCREEN:function(t,e){return"/"+t+"/"+e+"/fullscreen"},DECK_TAG:function(t,e){return"/"+t+"/decks/"+e},THEME_EDITOR:"/themes",BILLING_DETAILS:"/account/billing",TEAM:function(t){return window.location.protocol+"//"+t.get("slug")+"."+SL.config.APP_HOST},TEAM_EDIT:function(t){return SL.routes.TEAM(t)+"/edit"},TEAM_EDIT_MEMBERS:function(t){return SL.routes.TEAM(t)+"/edit_members"},isDeckView:function(){return $("html").hasClass("decks")}},SL.session={enforce:function(){this.enforced||(this.enforced=!0,this.hasLoggedOut=!1,this.loginInterval=setInterval(this.check.bind(this),SL.config.AUTH_STATUS_INTERVAL))},check:function(){$.get(SL.endpoints.CHECK_STATUS).done(function(t){t&&t.user_signed_in?this.onLoggedIn():this.onLoggedOut()}.bind(this))},onLoggedIn:function(){this.hasLoggedOut&&(this.hasLoggedOut=!1,SL.popup.close(SL.components.popup.SessionExpired))},onLoggedOut:function(){this.hasLoggedOut||(this.hasLoggedOut=!0,SL.popup.open(SL.components.popup.SessionExpired))}},SL.settings={STORAGE_KEY:"slides-settings",STORAGE_VERSION:1,EDITOR_AUTO_HIDE:"editorAutoHide",EDITOR_AUTO_SAVE:"editorAutoSave",EDITOR_CSS_WIDTH:"editorCSSWidth",init:function(){this.settings={version:this.STORAGE_VERSION},this.changed=new signals.Signal,this.restore()},setDefaults:function(){"undefined"==typeof this.settings[this.EDITOR_AUTO_HIDE]&&(this.settings[this.EDITOR_AUTO_HIDE]=!1),"undefined"==typeof this.settings[this.EDITOR_AUTO_SAVE]&&(this.settings[this.EDITOR_AUTO_SAVE]=!0)},setValue:function(t,e){"object"==typeof t?$.extend(this.settings,t):this.settings[t]=e,this.save(),this.changed.dispatch([t])},getValue:function(t){return this.settings[t]},removeValue:function(t){"object"==typeof t&&t.length?t.forEach(function(t){delete this.settings[t]}.bind(this)):delete this.settings[t],this.save(),this.changed.dispatch([t])},restore:function(){if(Modernizr.localstorage){var t=localStorage.getItem(this.STORAGE_KEY);if(t){var e=JSON.parse(localStorage.getItem(this.STORAGE_KEY));e&&e.version===this.STORAGE_VERSION?(this.settings=e,this.setDefaults(),this.changed.dispatch()):(this.setDefaults(),this.save())}}this.setDefaults()},save:function(){Modernizr.localstorage&&localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.settings))}},SL.util={noop:function(){},getQuery:function(){var t={};return location.search.replace(/[A-Z0-9\-\_]+?=([\w%\-]*)/gi,function(e){var i=e.split("=");t[i[0]]=decodeURIComponent(i[1])}),t},getDebugLevel:function(){return"number"!=typeof this.debugLevel&&(this.debugLevel=parseInt(SL.util.getQuery().debug,10),isNaN(this.debugLevel)&&(this.debugLevel=0)),this.debugLevel},getMetaKeyName:function(){return SL.util.device.isMac()?"&#8984":"CTRL"},getKeyboardShortcutName:function(t,e){e=e||{},this._metaKey=this._metaKey||(SL.util.device.isMac()?"&#8984":"Ctrl+");var i=[];return"string"==typeof t&&t.length>0&&(e.alt&&i.push("&#8997"),e.shift&&i.push("&#8679"),e.meta&&i.push(this._metaKey),e.ctrl&&i.push("&#8963"),e.casesensitive||(t=t.toUpperCase()),i.push(t)),e.span===!0&&(i.unshift('<span class="sl-keyboard-shortcut">'),i.push("</span>")),i.join("")},escapeHTMLEntities:function(t){return t=t||"",t=t.split("<").join("&lt;"),t=t.split(">").join("&gt;")},unescapeHTMLEntities:function(t){return(t||"").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&cent;/g,"\xa2").replace(/&pound;/g,"\xa3").replace(/&yen;/g,"\xa5").replace(/&euro;/g,"\u20ac").replace(/&copy;/g,"\xa9").replace(/&reg;/g,"\xae").replace(/&nbsp;/g," ")},toArray:function(t){for(var e=[],i=0,n=t.length;i<n;i++)e.push(t[i]);return e},parseCSSTransform:function(t){var e={};return(t||"").replace(/\s/g,"").split(")").forEach(function(t){t=t.trim().split("(");var i=t[0],n=t[1];n&&(n=n.split(",").map(function(t){return parseFloat(t.trim()||"0")})),i&&n&&(i=i.trim(),1===n.length?e[i]=n[0]:e[i]=n)}),e},skipCSSTransitions:function(t,e,i){t=t?$(t):$("html"),"function"!=typeof e||i||(i=e);var n=typeof t.get(0);"undefined"!==n&&"number"!==n||console.warn("Bad target for skipCSSTransitions."),t.addClass("no-transition"),setTimeout(function(){t.removeClass("no-transition"),"function"==typeof i&&i()},e||1)},setupReveal:function(t){if("undefined"!=typeof Reveal){var e={controls:!0,progress:!0,hash:!0,fragmentInURL:!0,mouseWheel:!1,pause:!1,hideInactiveCursor:!1,margin:SL.config.DEFAULT_SLIDE_MARGIN,autoSlideStoppable:!0,autoAnimateMatcher:SL.deck.AutoAnimate.matcher,highlight:{escapeHTML:!1},dependencies:[{src:SL.config.ASSET_URLS["reveal-plugins/zoom/zoom.js"],async:!0,callback:function(){Reveal.registerPlugin(RevealZoom)}},{src:SL.config.ASSET_URLS["reveal-plugins/markdown/markdown.js"],condition:function(){return!!document.querySelector(".reveal [data-markdown]")},callback:function(){Reveal.registerPlugin(RevealMarkdown)}},{src:SL.config.ASSET_URLS["reveal-plugins/highlight/highlight.js"],condition:function(){return!!document.querySelector(".reveal pre code")},callback:function(){Reveal.registerPlugin(RevealHighlight)}}]};SLConfig&&SLConfig.deck&&(e.width=SLConfig.deck.width,e.height=SLConfig.deck.height,e.margin=SLConfig.deck.margin,e.autoSlide=SLConfig.deck.auto_slide_interval||0,e.rollingLinks=SLConfig.deck.rolling_links,e.shuffle=SLConfig.deck.shuffle,e.center=SLConfig.deck.center,e.loop=SLConfig.deck.should_loop,e.rtl=SLConfig.deck.rtl,e.showNotes=SLConfig.deck.share_notes,e.slideNumber=SLConfig.deck.slide_number,e.navigationMode=SLConfig.deck.navigation_mode,e.transition=SLConfig.deck.transition||"default",e.backgroundTransition=SLConfig.deck.background_transition),$.extend(e,t),SLConfig&&SLConfig.deck&&SLConfig.deck.upsizing_enabled===!1&&(e.maxScale=1),SL.deck.util.injectNotes(),SL.deck.util.injectCodeCopyButtons(),Reveal.initialize(e).then(function(){window.STATUS=window.STATUS||{},window.STATUS.REVEAL_IS_READY=!0,$("html").addClass("reveal-is-ready");var t=$(".reveal .controls .navigate-right").css("color"),e=$(".reveal .controls .navigate-right").css("border-left-color");e&&"rgb(0, 0, 0)"!==e&&e!==t&&$(".reveal .controls").css("color",e)}),SL.deck.Controller.init({mode:e.presentationMode});var i=document.querySelector(".reveal .slides");if(t&&t.openLinksInTabs&&this.openLinksInTabs($(i)),t&&t.preventMediaDownloads&&this.preventMediaDownloads(i),t&&t.trackEvents){var n=[];Reveal.addEventListener("slidechanged",function(){var t=Reveal.getProgress();t>=.5&&!n[0]&&(n[0]=!0,SL.analytics.trackPresenting("Presentation progress: 50%")),t>=1&&!n[1]&&(n[1]=!0,SL.analytics.trackPresenting("Presentation progress: 100%")),SL.analytics.trackCurrentSlide()})}SL.deck.util.renderMath(i),SL.deck.util.injectTranslationRules()}},setupFloatingAd:function(){var t=$(".reveal-viewport #carbonads").length>0;if(t){var e=function(){$("html").toggleClass("hide-reveal-ad",!Reveal.isFirstSlide())};Reveal.addEventListener("slidechanged",e),Reveal.isReady()?e():Reveal.addEventListener("ready",e),$('<button class="carbon-dismiss white icon i-x" data-tooltip="Hide ad">').on("vclick",function(){$("#carbonads").remove()}).appendTo("#carbonads")}return t},openLinksInTabs:function(t){t&&t.find("a").each(function(){var t=$(this),e=t.attr("href");/^#/gi.test(e)===!0||this.hasAttribute("download")?t.removeAttr("target"):/http|www/gi.test(e)?t.attr("target","_blank"):/^mailto:/gi.test(e)?t.attr("target","_blank"):t.attr("target","_top")})},preventMediaDownloads:function(t){$(t).find("video").attr("controlsList","nodownload"),t.addEventListener("contextmenu",function(t){var e=t.target.tagName;if("VIDEO"===e||"IMG"===e)return t.preventDefault(),!1},!0)},openPopupWindow:function(t,e,i,n){var s=window.innerWidth/2-i/2,o=window.innerHeight/2-n/2;
"number"==typeof window.screenX&&(s+=window.screenX,o+=window.screenY);var a=window.open(t,e,"toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width="+i+", height="+n+", top="+o+", left="+s);return a.moveTo(s,o),a},prefixSelectorsInStyle:function(t,e){var i=[];SL.util.toArray(t.sheet.cssRules).forEach(function(t){if(1===t.type&&t.selectorText&&t.cssText){var n=t.cssText;n=n.replace(t.selectorText,""),n=n.trim(),n=n.slice(1,n.length-1),n=n.trim(),n=n.split(";").map(function(t){return t=t.trim(),""===t?"":"\n\t"+t}).join(";");var s=t.selectorText.split(",").map(function(t){return t=t.trim(),0===t.indexOf(e)?t:e+t}).join(", ");i.push(s+" {"+n+"\n}")}else 7===t.type&&t.cssText&&i.push(t.cssText)}),t.innerHTML="\n"+i.join("\n\n")+"\n"},layoutReveal:function(t,e){if(clearInterval(this.revealLayoutInterval),clearTimeout(this.revealLayoutTimeout),1===arguments.length)this.revealLayoutTimeout=setTimeout(Reveal.layout,t);else{if(2!==arguments.length)throw"Illegal arguments, expected (duration[, fps])";this.revealLayoutInterval=setInterval(Reveal.layout,e),this.revealLayoutTimeout=setTimeout(function(){clearInterval(this.revealLayoutInterval)}.bind(this),t)}},getRevealSlideBounds:function(t,e){t=t||SL.editor.controllers.Markup.getCurrentSlide();var i=t.offset(),n=Reveal.getScale(),s=i.left*n,o=i.top*n;if(e){var a=$(".projector").offset();a&&(s-=a.left,o-=a.top)}return{x:s,y:o,width:t.outerWidth()*n,height:t.outerHeight()*n}},getRevealSlidesBounds:function(t){var e=$(".reveal .slides"),i=e.offset(),n=Reveal.getScale(),s=i.left*n,o=i.top*n;if(t){var a=$(".projector").offset();a&&(s-=a.left,o-=a.top)}return{x:s,y:o,width:e.outerWidth()*n,height:e.outerHeight()*n}},getRevealElementOffset:function(t,e){t=$(t);var i={x:0,y:0};if(t.parents("section").length)for(;t.length&&!t.is("section");)i.x+=t.get(0).offsetLeft,i.y+=t.get(0).offsetTop,e&&(i.x-=parseInt(t.css("margin-left"),10),i.y-=parseInt(t.css("margin-top"),10)),t=$(t.get(0).offsetParent);return i},getRevealElementGlobalOffset:function(t){var e=$(t),i=e.closest(".reveal"),n={x:0,y:0};if(e.length&&i.length){var s=Reveal.getConfig(),o=Reveal.getScale(),a=i.get(0).getBoundingClientRect(),r={x:a.left+a.width/2,y:a.top+a.height/2},l=s.width*o,d=s.height*o;n.x=r.x-l/2,n.y=r.y-d/2;var c=e.closest(".slides section");c.length&&(n.y-=c.scrollTop()*o);var h=SL.util.getRevealElementOffset(e);n.x+=h.x*o,n.y+=h.y*o}return n},getRevealCounterScale:function(){return window.Reveal?2-Reveal.getScale():1},globalToRevealCoordinate:function(t,e){var i=SL.util.getRevealSlideBounds(),n=SL.util.getRevealCounterScale();return{x:(t-i.x)*n,y:(e-i.y)*n}},globalToProjectorCoordinate:function(t,e){var i={x:t,y:e},n=$(".projector").offset();return n&&(i.x-=n.left,i.y-=n.top),i},hideAddressBar:function(){if(SL.util.device.IS_PHONE&&!/crios/gi.test(navigator.userAgent)){var t=function(){setTimeout(function(){window.scrollTo(0,1)},10)};$(window).on("orientationchange",function(){t()}),t()}},callback:function(){"function"==typeof arguments[0]&&arguments[0].apply(null,[].slice.call(arguments,1))},getPlaceholderImage:function(t){var e="";return t&&"function"==typeof window.btoa&&(e=window.btoa(Math.random().toString()).replace(/=/g,"")),""+e},isMultiTouchEvent:function(t){if(window.TouchEvent){for(;t&&!(t instanceof window.TouchEvent);)t=t.originalEvent;if(t&&t.touches&&t.touches.length>1)return!0}return!1},isTypingEvent:function(t){return $(t.target).is('input:not([type="file"]), textarea, [contenteditable]')},isTyping:function(){var t=document.activeElement&&"inherit"!==document.activeElement.contentEditable,e=document.activeElement&&document.activeElement.tagName&&/input|textarea/i.test(document.activeElement.tagName);return t||e},createCodeEditor:function(t,e){return CodeMirror.defaults.theme="seti",CodeMirror.defaults.lineNumbers=!0,CodeMirror.defaults.continueComments=!0,CodeMirror.defaults.autoCloseBrackets=!0,CodeMirror.defaults.autoCloseTags=!0,CodeMirror.defaults.matchBrackets=!0,CodeMirror.defaults.extraKeys={"Cmd-/":"toggleComment","Ctrl-/":"toggleComment"},CodeMirror(t,e)},copyToClipboard:function(t){var e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select();var i=document.execCommand("copy");return document.body.removeChild(e),i},isInIframe:function(){try{return window.self!==window.top}catch(t){return!0}},parseJSON:function(t){if("string"==typeof t&&/^\{.*\}$/.test(t))try{return JSON.parse(t)}catch(t){}return null}},SL.util.user={isLoggedIn:function(){return"object"==typeof SLConfig&&"object"==typeof SLConfig.current_user},isLoggedInDeckOwner:function(){return!!(SL.util.user.isLoggedIn()&&SLConfig.deck&&SLConfig.deck.user&&SLConfig.deck.user.id===SLConfig.current_user.id)},isPseudoLoggedIn:function(){return"object"==typeof SLConfig&&!!SLConfig.pseudo_signed_in}},SL.util.device={HAS_TOUCH:!!("ontouchstart"in window),IS_PHONE:/iphone|ipod|android|windows\sphone/gi.test(navigator.userAgent),IS_TABLET:/ipad/gi.test(navigator.userAgent),isMac:function(){return/Mac/.test(navigator.platform)},isWindows:function(){return/Win/g.test(navigator.platform)},isLinux:function(){return/Linux/g.test(navigator.platform)},isIE:function(){return/MSIE\s[0-9]/gi.test(navigator.userAgent)||/Trident\/7.0;(.*)rv:\d\d/.test(navigator.userAgent)},isChrome:function(){return/chrome/gi.test(navigator.userAgent)},isSafari:function(){return/safari/gi.test(navigator.userAgent)&&!SL.util.device.isChrome()},isiPhone:function(){return/iphone|ipod/gi.test(navigator.userAgent)},isSafariDesktop:function(){return SL.util.device.isSafari()&&!SL.util.device.isChrome()&&!SL.util.device.IS_PHONE&&!SL.util.device.IS_TABLET},isOpera:function(){return!!window.opera},isFirefox:function(){return/firefox\/\d+\.?\d+/gi.test(navigator.userAgent)},isPhantomJS:function(){return/PhantomJS/gi.test(navigator.userAgent)},supportedByEditor:function(){return Modernizr.history&&Modernizr.csstransforms&&!SL.util.device.isOpera()},getScrollBarWidth:function(){var t=$("<div>").css({width:"100px",height:"100px",overflow:"scroll",position:"absolute",top:"-9999px"});t.appendTo(document.body);var e=t.prop("offsetWidth")-t.prop("clientWidth");return t.remove(),e}},SL.util.trig={distanceBetween:function(t,e){var i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},intersection:function(t,e){return{x:Math.max(t.x,e.x),y:Math.max(t.y,e.y),width:Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),height:Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y))}},intersects:function(t,e,i,n){"undefined"==typeof i&&(i=0),"undefined"==typeof n&&(n=i);var s=SL.util.trig.intersection(t,e);return s.width>t.width*i&&s.height>t.height*n},isPointWithinRect:function(t,e,i){return t>i.x&&t<i.x+i.width&&e>i.y&&e<i.y+i.height},findLineIntersection:function(t,e,i,n){var s={x:e.x-t.x,y:e.y-t.y},o={x:n.x-i.x,y:n.y-i.y},a=(-s.y*(t.x-i.x)+s.x*(t.y-i.y))/(-o.x*s.y+s.x*o.y),r=(o.x*(t.y-i.y)-o.y*(t.x-i.x))/(-o.x*s.y+s.x*o.y);return a>=0&&a<=1&&r>=0&&r<=1?{x:t.x+r*s.x,y:t.y+r*s.y}:null},rotateAround:function(t,e,i,n,s){return s=s*Math.PI/180,{x:(t-i)*Math.cos(s)-(e-n)*Math.sin(s)+i,y:(t-i)*Math.sin(s)+(e-n)*Math.cos(s)+n}},rotateBoundingBox:function(t,e,i,n){i="number"==typeof i?i:t.x+t.width/2,n="number"==typeof n?n:t.y+t.height/2;var s=SL.util.trig.rotateAround(t.x,t.y,i,n,e),o=SL.util.trig.rotateAround(t.right,t.y,i,n,e),a=SL.util.trig.rotateAround(t.right,t.bottom,i,n,e),r=SL.util.trig.rotateAround(t.x,t.bottom,i,n,e);return SL.util.trig.cornersToBoundingBox(s,o,a,r)},cornersToBoundingBox:function(t,e,i,n){var s={};return s.x=Math.min(t.x,e.x,i.x,n.x),s.y=Math.min(t.y,e.y,i.y,n.y),s.right=Math.max(t.x,e.x,i.x,n.x),s.bottom=Math.max(t.y,e.y,i.y,n.y),s.width=s.right-s.x,s.height=s.bottom-s.y,s}},SL.util.array={shuffle:function(t){for(var e=t.length-1;e>0;e--){var i=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[i],t[i]=n}return t}},SL.util.string={URL_REGEX:/((https?\:\/\/)|(www\.)|(^\/\/))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i,SCRIPT_TAG_REGEX:/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,VIMEO_ID_REGEX:/vimeo.com\/(\d+)/i,YOUTUBE_ID_REGEX:/youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)/i,YOUTUBE_SHORT_ID_REGEX:/youtu\.be\/([a-zA-Z0-9_-]+)/i,VIMEO_EMBED_URL_REGEX:/player\.vimeo\.com\/video\/\d+/i,YOUTUBE_EMBED_URL_REGEX:/youtube\.com\/embed\/([a-zA-Z0-9_-]+)/i,VIMEO_EMBED_URL:"https://player.vimeo.com/video/{{VIDEO_ID}}",YOUTUBE_EMBED_URL:"https://www.youtube.com/embed/{{VIDEO_ID}}",CODEPEN_PEN_REGEX:/(\/\/codepen\.io\/[^\/]+\/)(pen)(\/.{3,})/i,uniqueIDCount:0,uniqueID:function(t){return SL.util.string.uniqueIDCount+=1,(t||"")+SL.util.string.uniqueIDCount+"-"+Date.now()},slug:function(t){return"string"==typeof t?(t=SL.util.string.trim(t),t=t.toLowerCase(),t=t.replace(/-/g," "),t=t.replace(/[^\w\s]/g,""),t=t.replace(/\s{2,}/g," "),t=t.replace(/\s/g,"-")):""},trim:function(t){return SL.util.string.trimRight(SL.util.string.trimLeft(t))},trimLeft:function(t){return"string"==typeof t?t.replace(/^\s+/,""):""},trimRight:function(t){return"string"==typeof t?t.replace(/\s+$/,""):""},linkify:function(t){return t&&(t=t.replace(/((https?\:\/\/)|(www\.))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi,function(t){var e=t;return e.match("^https?://")||(e="http://"+e),'<a href="'+e+'">'+t+"</a>"})),t},pluralize:function(t,e,i){return i?t+e:t},toTitleCase:function(t){return t.replace(/\w\S*/g,function(t){return t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()})},viewCount:function(t){return t<1e4?t:t=SL.util.math.limitDecimals(t/1e3,1)+"k"},getCustomClassesFromLESS:function(t){var e=(t||"").match(/\/\/=[a-z0-9-_ \t]{2,}(?=\n)?/gi);return e?e.map(function(t){return t=t.replace("//=",""),t=t.trim(),t=t.toLowerCase(),t=t.replace(/\s/g,"-")}):[]},moveCSSImportsToBeginning:function(t){var e="";return t=t.replace(/@import url\(["'\s]*(http:|https:)?\/\/(.*)\);?/gi,function(t){return e+=t+"\n",""}),e+t},formatIframeSource:function(t){if(t=(t||"").trim(),/<iframe/gi.test(t)){try{var e=$(t);t=e.is("iframe")?e.attr("src"):e.find("iframe").attr("src")}catch(t){}t||(t="",SL.notify("Unable to find iframe source attribute. Please try pasting the URL directly."))}var i=t.match(SL.util.string.VIMEO_ID_REGEX);if(i&&2===i.length&&"string"==typeof i[1])return SL.util.string.VIMEO_EMBED_URL.replace(/{{VIDEO_ID}}/,i[1]);var n=t.match(SL.util.string.YOUTUBE_ID_REGEX);if(n&&2===n.length&&"string"==typeof n[1])return SL.util.string.YOUTUBE_EMBED_URL.replace("{{VIDEO_ID}}",n[1]);var s=t.match(SL.util.string.YOUTUBE_SHORT_ID_REGEX);return s&&2===s.length&&"string"==typeof s[1]?SL.util.string.YOUTUBE_EMBED_URL.replace("{{VIDEO_ID}}",s[1]):SL.util.string.CODEPEN_PEN_REGEX.test(t)?t.replace(SL.util.string.CODEPEN_PEN_REGEX,"$1embed$3"):t},isIframeVideoURL:function(t){return t=SL.util.string.formatIframeSource(t),SL.util.string.VIMEO_EMBED_URL_REGEX.test(t)||SL.util.string.YOUTUBE_EMBED_URL_REGEX.test(t)}},SL.util.math={limitDecimals:function(t,e){var i=Math.pow(10,e);return Math.round(t*i)/i},bytesToMegabytes:function(t,e){return e?Math.round(t/1024/1024):t/1024/1024},fitWithin:function(t,e,i,n){var s=Math.min(i/t,n/e);return{width:t*s,height:e*s}},fitOutside:function(t,e,i,n){var s=Math.max(i/t,n/e);return{width:t*s,height:e*s}}},SL.util.validate={name:function(){return[]},slug:function(t){t=t||"";var e=[];return t.length<2&&e.push("At least 2 characters"),/\s/gi.test(t)&&e.push("No spaces please"),/^[\w-_]+$/gi.test(t)||e.push("Can only contain: A-Z, 0-9, - and _"),e},username:function(t){return SL.util.validate.slug(t)},team_slug:function(t){return SL.util.validate.slug(t)},password:function(t){t=t||"";var e=[];return t.length<6&&e.push("At least 6 characters"),e},email:function(t){t=t||"";var e=[];return/^[A-Z0-9._%+\-]+@[A-Z0-9.\-]+\.[A-Z]{2,}$/gi.test(t)||e.push("Please enter a valid email"),e},twitterhandle:function(t){t=t||"";var e=[];return t.length>15&&e.push("15 characters max"),/\s/gi.test(t)&&e.push("No spaces please"),/^[\w-_]+$/gi.test(t)||e.push("Can only contain: A-Z, 0-9 and _"),e},url:function(t){t=t||"";var e=[];return t.length<4&&e.push("Please enter a valid URL"),/\s/gi.test(t)&&e.push("No spaces please"),e},decktitle:function(t){t=t||"";var e=[];return 0===t.length&&e.push("Can not be empty"),e},deckslug:function(t){t=t||"";var e=[];return 0===t.length&&e.push("Can not be empty"),e},google_analytics_id:function(t){t=t||"";var e=[];return/\b(UA|G)-\d{4,20}(-\d{1,20})?\b/gi.test(t)||e.push("Please enter a valid ID"),e},google_domain:function(t){t=t||"";var e=[];return/\./gi.test(t)||e.push("Please enter a valid domain"),e},none:function(){return[]}},SL.util.dom={scrollIntoViewIfNeeded:function(t){t&&("function"==typeof t.scrollIntoViewIfNeeded?t.scrollIntoViewIfNeeded.apply(t,[].slice.call(arguments,1)):"function"==typeof t.scrollIntoView&&t.scrollIntoView())},preventTouchOverflowScrolling:function(t){t=$(t);var e,i,n;t.get(0).addEventListener("touchstart",function(t){e=this.scrollTop>0,i=this.scrollTop<this.scrollHeight-this.clientHeight,n=t.pageY}),t.get(0).addEventListener("touchmove",function(t){var s=t.pageY>n,o=!s;n=t.pageY,s&&e||o&&i?t.stopPropagation():t.preventDefault()})},insertCSRF:function(t,e){"undefined"==typeof e&&(e=$('meta[name="csrf-token"]').attr("content")),e&&(t.find('input[name="authenticity_token"]').remove(),t.append('<input name="authenticity_token" type="hidden" value="'+e+'" />'))},calculateStyle:function(t){window.getComputedStyle($(t).get(0)).opacity},swapElements:function(t,e){var i=$("<div>").insertAfter(t);t.insertAfter(e),e.insertBefore(i),i.remove()}},SL.util.html={indent:function(t){return html_beautify(t)},ATTR_SRC_NORMAL:"src",ATTR_SRC_SILENCED:"data-silenced-src",ATTR_SRC_NORMAL_REGEX:" src=",ATTR_SRC_SILENCED_REGEX:" data-silenced-src=",muteSources:function(t){return(t||"").replace(new RegExp(SL.util.html.ATTR_SRC_NORMAL_REGEX,"gi"),SL.util.html.ATTR_SRC_SILENCED_REGEX)},unmuteSources:function(t){return(t||"").replace(new RegExp(SL.util.html.ATTR_SRC_SILENCED_REGEX,"gi"),SL.util.html.ATTR_SRC_NORMAL_REGEX)},trimCode:function(t){$(t).find("pre code").each(function(){var t=$(this).parent("pre"),e=t.html(),i=$.trim(e);e!==i&&t.html(i)})},removeAttributes:function(t,e){t=$(t);var i=$.map(t.get(0).attributes,function(t){return t.name});"function"==typeof e&&(i=i.filter(e)),$.each(i,function(e,i){t.removeAttr(i)})},removeClasses:function(t,e){if(t=$(t),"function"==typeof e){var i=(t.attr("class")||"").split(" ").filter(e);t.removeClass(i.join(" "))}else t.attr("class","")},findScriptTags:function(t){var e=document.createElement("div");e.innerHTML=t;var i=SL.util.toArray(e.getElementsByTagName("script"));return i.map(function(t){return t.outerHTML})},removeScriptTags:function(t){var e=document.createElement("div");e.innerHTML=t;var i=SL.util.toArray(e.getElementsByTagName("script"));return i.forEach(function(t){t.parentNode.removeChild(t)}),e.innerHTML},createSpinner:function(t){return t=$.extend({lines:12,radius:8,length:6,width:3,color:"#fff",zIndex:"auto",left:"0",top:"0",className:""},t),new Spinner(t)},generateSpinners:function(){$(".spinner").each(function(t,e){if(e.hasAttribute("data-spinner-state")===!1){e.setAttribute("data-spinner-state","spinning");var i={};e.hasAttribute("data-spinner-color")&&(i.color=e.getAttribute("data-spinner-color")),e.hasAttribute("data-spinner-lines")&&(i.lines=parseInt(e.getAttribute("data-spinner-lines"),10)),e.hasAttribute("data-spinner-width")&&(i.width=parseInt(e.getAttribute("data-spinner-width"),10)),e.hasAttribute("data-spinner-radius")&&(i.radius=parseInt(e.getAttribute("data-spinner-radius"),10)),e.hasAttribute("data-spinner-length")&&(i.length=parseInt(e.getAttribute("data-spinner-length"),10));var n=SL.util.html.createSpinner(i);$(e).data("spinner",n),n.spin(e)}})}},SL.util.deck={idCounter:1,sortInjectedStyles:function(){var t=$("head");$("#theme-css-output").appendTo(t),$("#user-css-output").appendTo(t)},afterSlidesChanged:function(){this.generateIdentifiers(),this.generateSlideNumbers()},generateIdentifiers:function(t){$(t||".reveal .slides section").each(function(){this.hasAttribute("data-id")!==!1&&0!==this.getAttribute("data-id").length||this.setAttribute("data-id",CryptoJS.MD5(["slide",SL.current_user.get("id"),SL.current_deck.get("id"),Date.now(),SL.util.deck.idCounter++].join("-")).toString())}),this.generateSlideNumbers()},generateSlideNumbers:function(){this.slideNumberMap={},$(".reveal .slides>section[data-id]").each(function(t,e){t+=1,e=$(e),e.hasClass("stack")?e.find(">section[data-id]").each(function(e,i){e+=1,i=$(i),this.slideNumberMap[i.attr("data-id")]=t+(e>1?"."+e:"")}.bind(this)):this.slideNumberMap[e.attr("data-id")]=t}.bind(this))},getSlideNumber:function(t){return this.slideNumberMap||this.generateSlideNumbers(),this.slideNumberMap[this.getSlideID(t)]},getSlideID:function(t){return"string"==typeof t?t:t&&"function"==typeof t.getAttribute?t.getAttribute("data-id"):t&&"function"==typeof t.attr?t.attr("data-id"):void 0},getSlideIndicesFromIdentifier:function(t){var e=$('.reveal .slides section[data-id="'+t+'"]');return e.length?Reveal.getIndices(e.get(0)):null},getBackgroundColor:function(){var t=$(".reveal-viewport");if(t.length){var e=t.css("background-color");if(window.Reveal&&window.Reveal.isReady()){var i=window.Reveal.getIndices(),n=window.Reveal.getSlideBackground(i.h,i.v);if(n){var s=n.style.backgroundColor;s&&window.tinycolor(s).getAlpha()>0&&(e=s)}}if(e)return e}return"#ffffff"},getBackgroundContrast:function(){return SL.util.color.getContrast(SL.util.deck.getBackgroundColor())},getBackgroundBrightness:function(){return SL.util.color.getBrightness(SL.util.deck.getBackgroundColor())},getSlideSize:function(){if(Reveal&&Reveal.isReady()){var t=Reveal.getConfig();return{width:t.width,height:t.height}}return window.SLConfig&&window.SLConfig.deck?{width:window.SLConfig.deck.width,height:window.SLConfig.deck.height}:{width:SL.config.DEFAULT_SLIDE_WIDTH,height:SL.config.DEFAULT_SLIDE_HEIGHT}},navigateToSlide:function(t){if(t){var e=Reveal.getIndices(t);Reveal.slide(e.h,e.v)}},replaceUserCSS:function(t){var e=$("#user-css-output");0===e.length&&(e=$('<style id="user-css-output" type="text/css"></style>').appendTo("head"),SL.util.deck.sortInjectedStyles()),e.html(t||"")},replaceHTML:function(t,e){e=e||{},SL.util.skipCSSTransitions($(".reveal"),1);var i=Reveal.getState(),n=document.querySelector(".reveal .slides");n.innerHTML=t,$('.reveal section[data-visibility="hidden"]').remove(),Reveal.setState(i),"function"==typeof e.beforeSync&&e.beforeSync(),Reveal.sync(),SL.deck.util.renderMath(n),SL.deck.Animation.sync(),this.afterSlidesChanged();var s=Reveal.getPlugin("highlight");s&&(SL.deck.util.injectCodeCopyButtons(),$(".reveal .slides pre code").each(function(){s.highlightBlock(this)}))},reloadDeck:function(t,e){return $.ajax({url:t,type:"GET"}).done(function(t){if(t&&t.data){t.width&&e.set("width",t.width),t.height&&e.set("height",t.height),t.theme_color&&e.set("theme_color",t.theme_color),t.theme_font&&e.set("theme_font",t.theme_font),t.transition&&e.set("transition",t.transition),t.notes&&e.set("notes",t.notes),"string"==typeof t.css_output&&SL.util.deck.replaceUserCSS(t.css_output);var i=SL.models.Theme.fromDeck(e.toJSON());SL.helpers.ThemeController.paint(i,{center:!1}),SL.util.deck.replaceHTML(t.data,{beforeSync:function(){t.notes&&SL.deck.util.injectNotes()}})}})},removeSlideBackground:function(t,e){["image","size","position","opacity","video","video-muted","video-loop","video-thumb","video-processing","media-id","iframe","interactive"].forEach(function(i){e&&e.indexOf(i)!==-1||t.removeAttribute("data-background-"+i)},this)},hasMediaThatRequiresUserInteraction:function(){return document.querySelectorAll(".reveal video:not([muted])").length>0}},SL.util.color={getContrast:function(t){var e=window.tinycolor(t).toRgb(),i=(299*e.r+587*e.g+114*e.b)/1e3;return i/255},getBrightness:function(t){var e=window.tinycolor(t).toRgb(),i=e.r/255*.3+e.g/255*.59+(e.b/255+.11);return i/2},getImageColor:function(t,e){return new Promise(function(i,n){var s=document.createElement("img");s.addEventListener("load",function(){var t,o=document.createElement("canvas"),a=o.getContext&&o.getContext("2d"),r={r:0,g:0,b:0,a:0};a||n();var l=o.height=s.naturalHeight||s.offsetHeight||s.height,d=o.width=s.naturalWidth||s.offsetWidth||s.width;a.drawImage(s,0,0);try{t=a.getImageData(0,0,d,l)}catch(t){n()}var c=4,h=t.data.length,u=0;if("number"!=typeof e&&(e=8,"number"==typeof h))for(;h/e>5e4;)e+=8;for(;(c+=4*e)<h;)++u,r.r+=t.data[c],r.g+=t.data[c+1],r.b+=t.data[c+2],r.a+=t.data[c+3];r.r=~~(r.r/u),r.g=~~(r.g/u),r.b=~~(r.b/u),r.a=~~(r.a/u),r.a=r.a/255,i(r)}),s.addEventListener("error",function(){n()}),s.setAttribute("crossorigin","anonymous"),s.setAttribute("src",t)})}},SL.util.anim={collapseListItem:function(t,e,i){t=$(t),t.addClass("no-transition"),t.css({overflow:"hidden"}),t.animate({opacity:0,height:0,minHeight:0,paddingTop:0,paddingBottom:0,marginTop:0,marginBottom:0},{duration:i||500,complete:e})},collapseListItemHorizontal:function(t,e,i){t=$(t),t.addClass("no-transition"),t.css({overflow:"hidden","white-space":"nowrap"}),t.animate({opacity:0,width:0,minWidth:0,paddingLeft:0,paddingRight:0,marginLeft:0,marginRight:0},{duration:i||500,complete:e})},countTo:function(t,e,i){e===i||isNaN(parseFloat(e))||isNaN(parseFloat(i))||$(t).each(function(){$(this).prop("counter",e).animate({counter:i},{duration:500,step:function(t){$(this).text(Math.round(t))},complete:function(){$(this).text(i)}})})}},SL.util.social={getFacebookShareLink:function(t,e,i,n){return"http://www.facebook.com/sharer.php?s=100&p[title]="+encodeURIComponent(e)+"&p[summary]="+encodeURIComponent(i)+"&p[url]="+t+"&p[images][0]="+n},getTwitterShareLink:function(t,e){return"http://twitter.com/share?text="+encodeURIComponent(e)+"&url="+encodeURIComponent(t)+"&via=slides"},getGoogleShareLink:function(t){return"https://plus.google.com/share?url="+encodeURIComponent(t)}},SL.util.selection={clear:function(){window.getSelection&&(window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().removeAllRanges())},moveCursorToEnd:function(t){if(t){t.focus();var e=document.createRange();e.selectNodeContents(t),e.collapse(!1),selection=window.getSelection(),selection.removeAllRanges(),selection.addRange(e)}},selectText:function(t){var e,i;document.body.createTextRange?(e=document.body.createTextRange(),e.moveToElementText(t),e.select()):window.getSelection&&(i=window.getSelection(),e=document.createRange(),e.selectNodeContents(t),i.removeAllRanges(),i.addRange(e))},getSelectedElement:function(){var t=window.getSelection();return t&&t.anchorNode?t.anchorNode.parentNode:null},getSelectedTags:function(){var t=SL.util.selection.getSelectedElement(),e=[];if(t)for(;t;)e.push(t.nodeName.toLowerCase()),t=t.parentNode;return e},getSelectedHTML:function(){var t;if(document.selection&&document.selection.createRange)return t=document.selection.createRange(),t.htmlText;if(window.getSelection){var e=window.getSelection();if(e.rangeCount>0){t=e.getRangeAt(0);var i=t.cloneContents(),n=document.createElement("div");return n.appendChild(i),n.innerHTML}}return""}},"undefined"!=typeof window.Spinner&&"undefined"!=typeof SL.util&&SL.util.html.generateSpinners(),SL.visibility={init:function(){this.changed=new signals.Signal,"undefined"!=typeof document.hidden?(this.hiddenProperty="hidden",this.visibilityChangeEvent="visibilitychange"):"undefined"!=typeof document.msHidden?(this.hiddenProperty="msHidden",this.visibilityChangeEvent="msvisibilitychange"):"undefined"!=typeof document.webkitHidden&&(this.hiddenProperty="webkitHidden",this.visibilityChangeEvent="webkitvisibilitychange"),this.supported="boolean"==typeof document[this.hiddenProperty],this.supported&&this.bind()},isVisible:function(){return!this.supported||!document[this.hiddenProperty]},isHidden:function(){return!!this.supported&&document[this.hiddenProperty]},bind:function(){document.addEventListener(this.visibilityChangeEvent,this.onVisibilityChange.bind(this))},onVisibilityChange:function(){this.changed.dispatch()}},SL.warnings={STORAGE_KEY:"slides-last-warning-id",MESSAGE_ID:23,init:function(){this.showMessage()},showMessage:function(){if(this.hasMessage()&&!this.hasExpired()&&SL.util.user.isLoggedIn()&&Modernizr.localstorage){var t=parseInt(localStorage.getItem(this.STORAGE_KEY),10)||0;if(t<this.MESSAGE_ID){var e=SL.notify(this.MESSAGE_TEXT,{optional:!1});e.destroyed.add(this.hideMessage.bind(this))}}},hideMessage:function(){Modernizr.localstorage&&localStorage.setItem(this.STORAGE_KEY,this.MESSAGE_ID)},hasMessage:function(){return!!this.MESSAGE_TEXT},hasExpired:function(){return!!this.MESSAGE_EXPIRY&&moment().diff(moment(this.MESSAGE_EXPIRY))>0}},SL("helpers").FileUploader=Class.extend({init:function(t){if(this.options=$.extend({formdata:!0,formdataFields:{},contentType:!1,external:!1,method:"POST"},t),"undefined"==typeof this.options.file||"undefined"==typeof this.options.endpoint)throw"File and upload endpoint must be defined for FileUploader task.";this.timeout=-1,this.uploading=!1,this.onUploadSuccess=this.onUploadSuccess.bind(this),this.onUploadProgress=this.onUploadProgress.bind(this),this.onUploadError=this.onUploadError.bind(this),this.failed=new signals.Signal,this.succeeded=new signals.Signal,this.progressed=new signals.Signal},upload:function(){if(this.uploading=!0,clearTimeout(this.timeout),"number"==typeof this.options.timeout&&(this.timeout=setTimeout(this.onUploadError,this.options.timeout)),this.xhr=new XMLHttpRequest,this.xhr.onload=function(){if(this.options.external===!0)this.onUploadSuccess();else if(422===this.xhr.status||500===this.xhr.status)this.onUploadError();else{try{var t=JSON.parse(this.xhr.responseText)}catch(t){return this.onUploadError()}this.onUploadSuccess(t)}}.bind(this),this.xhr.onerror=this.onUploadError,this.xhr.upload.onprogress=this.onUploadProgress,this.xhr.open(this.options.method,this.options.endpoint,!0),this.options.contentType){var t="string"==typeof this.options.contentType?this.options.contentType:this.options.file.type;t&&this.xhr.setRequestHeader("Content-Type",t)}if(this.options.formdata){var e=new FormData;if(this.options.filename?e.append("file",this.options.file,this.options.filename):e.append("file",this.options.file),this.options.formdataFields)for(var i in this.options.formdataFields)e.append(i,this.options.formdataFields[i]);var n=this.options.csrf||document.querySelector('meta[name="csrf-token"]');n&&!this.options.external&&e.append("authenticity_token",n.getAttribute("content")),this.xhr.send(e)}else this.xhr.send(this.options.file)},isUploading:function(){return this.uploading},onUploadSuccess:function(t){clearTimeout(this.timeout),this.uploading=!1,this.succeeded.dispatch(t)},onUploadProgress:function(t){t.lengthComputable&&this.progressed.dispatch(t.loaded/t.total)},onUploadError:function(){clearTimeout(this.timeout),this.uploading=!1,this.failed.dispatch()},destroy:function(){if(clearTimeout(this.timeout),this.xhr){var t=function(){};this.xhr.onload=t,this.xhr.onerror=t,this.xhr.upload.onprogress=t,this.xhr.abort()}this.succeeded.dispose(),this.progressed.dispose(),this.failed.dispose()}}),SL.helpers.Fullscreen={enter:function(t){t=t||document.body;var e=this.getRequestMethod(t);e&&e.apply(t)},exit:function(){var t=document.exitFullscreen||document.msExitFullscreen||document.mozCancelFullScreen||document.webkitExitFullscreen;t&&t.apply(document)},toggle:function(){SL.helpers.Fullscreen.isActive()?SL.helpers.Fullscreen.exit():SL.helpers.Fullscreen.enter()},isEnabled:function(){var t=document.fullscreenEnabled||document.mozFullscreenEnabled||document.msFullscreenEnabled||document.webkitFullscreenEnabled;return"boolean"==typeof t?t:!!this.getRequestMethod(document.body)},isActive:function(){return!!(document.fullscreenElement||document.msFullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement)},getRequestMethod:function(t){return t.requestFullScreen||t.webkitRequestFullscreen||t.webkitRequestFullScreen||t.mozRequestFullScreen||t.msRequestFullscreen}},SL("helpers").MediaUploader=Class.extend({init:function(t){if(this.options=$.extend({type:"Image",contentType:!1,endpoint:SL.endpoints.MEDIA_CREATE,timeout:null},t),"undefined"==typeof this.options.file)throw"File must be defined for MediaUploader task.";this.timeout=-1,this.uploading=!1,this.onCreateSuccess=this.onCreateSuccess.bind(this),this.onFinishSuccess=this.onFinishSuccess.bind(this),this.onUploadSuccess=this.onUploadSuccess.bind(this),this.onUploadProgress=this.onUploadProgress.bind(this),this.onError=this.onError.bind(this),this.failed=new signals.Signal,this.succeeded=new signals.Signal,this.progressed=new signals.Signal},start:function(){clearTimeout(this.timeout),"number"==typeof this.options.timeout&&(this.timeout=setTimeout(this.onError,this.options.timeout)),this.uploading=!0,this.create()},create:function(){$.ajax({url:this.options.endpoint,type:"POST",data:{type:this.options.type,filename:this.options.filename},context:this}).done(this.onCreateSuccess).fail(this.onError)},onCreateSuccess:function(t){this.options.media?this.options.media.setAll(t):this.options.media=SL.models.Media.create(t),this.upload()},upload:function(){if(this.uploadXHR=new XMLHttpRequest,this.uploadXHR.onload=function(){422===this.uploadXHR.status||500===this.uploadXHR.status?this.onError():this.onUploadSuccess()}.bind(this),this.uploadXHR.onerror=this.onError,this.uploadXHR.upload.onprogress=this.onUploadProgress,this.uploadXHR.open("PUT",this.options.media.get("upload_url"),!0),this.options.contentType){var t="string"==typeof this.options.contentType?this.options.contentType:this.options.file.type;t&&this.uploadXHR.setRequestHeader("Content-Type",t)}this.uploadXHR.send(this.options.file)},onUploadProgress:function(t){t.lengthComputable&&this.progressed.dispatch(t.loaded/t.total)},onUploadSuccess:function(){this.finish()},finish:function(){this.options.media.set("status","upload_complete"),this.options.media.save(["status"]).then(this.onFinishSuccess,this.onError)},onFinishSuccess:function(t){clearTimeout(this.timeout),this.uploading=!1,this.succeeded.dispatch(t)},isUploading:function(){return this.uploading},onError:function(){clearTimeout(this.timeout),this.uploading=!1,this.failed.dispatch()},destroy:function(){if(clearTimeout(this.timeout),this.uploadXHR){var t=function(){};this.uploadXHR.onload=t,this.uploadXHR.onerror=t,this.uploadXHR.upload.onprogress=t,this.uploadXHR.abort()}this.succeeded.dispose(),this.progressed.dispose(),this.failed.dispose()}}),SL.helpers.PageLoader={show:function(t){t=$.extend({style:null,message:null},t);var e=$(".page-loader");0===e.length&&(e=$(['<div class="page-loader">','<div class="page-loader-inner hidden">','<div class="page-loader-spinner spinner"></div>','<p class="page-loader-message"></p>',"</div>","</div>"].join("")).appendTo(document.body),setTimeout(function(){e.find(".page-loader-inner").removeClass("hidden")},1)),t.container&&e.appendTo(t.container),t.message&&e.find(".page-loader-message").html(t.message),t.style&&e.attr("data-style",t.style),clearTimeout(this.hideTimeout),e.removeClass("frozen"),e.addClass("visible")},hide:function(){$(".page-loader").removeClass("visible"),clearTimeout(this.hideTimeout),this.hideTimeout=setTimeout(function(){$(".page-loader").addClass("frozen")}.bind(this),1e3)},waitForFonts:function(t){SL.fonts.isReady()===!1?(this.show(t),SL.fonts.ready.add(this.hide)):this.hide()}},SL("helpers").PollJob=Class.extend({init:function(t){this.options=$.extend({interval:1e3,timeout:Number.MAX_VALUE,retries:Number.MAX_VALUE,invokeAsap:!1},t),this.interval=-1,this.running=!1,this.poll=this.poll.bind(this),this.ended=new signals.Signal,this.polled=new signals.Signal},start:function(){this.running=!0,this.pollStart=Date.now(),this.pollTimes=0,this.options.invokeAsap&&this.poll(),clearInterval(this.interval),this.interval=setInterval(this.poll,this.options.interval)},stop:function(){this.running=!1,clearInterval(this.interval)},poll:function(){this.pollTimes++,Date.now()-this.pollStart>this.options.timeout||this.pollTimes>this.options.retries?(this.stop(),this.ended.dispatch()):this.polled.dispatch()},destroy:function(){this.stop(),this.polled.dispose(),this.ended.dispose()}}),SL("helpers").StreamEditor=Class.extend({init:function(t){this.options=$.extend({},t),this.statusChanged=new signals.Signal,this.reconnecting=new signals.Signal,this.messageReceived=new signals.Signal,this.debugMode=!!SL.util.getQuery().debug},connect:function(){if(this.socket)this.isConnected()||(this.log("manual reconnect",t),this.socket.io.close(),this.socket.io.open());else{
var t=SL.config.STREAM_ENGINE_HOST+"/"+SL.config.STREAM_ENGINE_EDITOR_NAMESPACE;this.log("connecting to",t),this.socket=io.connect(t,{reconnectionDelayMax:1e4}),this.socket.on("connect",this.onSocketConnect.bind(this)),this.socket.on("reconnect_attempt",this.onSocketReconnectAttempt.bind(this)),this.socket.on("reconnect_failed",this.onSocketReconnectFailed.bind(this)),this.socket.on("reconnect",this.onSocketReconnect.bind(this)),this.socket.on("disconnect",this.onSocketDisconnect.bind(this)),this.socket.on("message",this.onSocketMessage.bind(this))}return this.isConnected()?Promise.resolve():new Promise(function(t,e){var i=function(){t(),this.socket.removeEventListener("connect",i),this.socket.removeEventListener("connect_error",n)}.bind(this),n=function(){e(),this.socket.removeEventListener("connect",i),this.socket.removeEventListener("connect_error",n)}.bind(this);this.socket.on("connect",i),this.socket.on("connect_error",n)}.bind(this))},broadcast:function(t){this.emit("broadcast",JSON.stringify(t))},emit:function(){this.log("emit",arguments),this.socket.emit.apply(this.socket,arguments)},log:function(){if(this.debugMode&&"function"==typeof console.log.apply){var t=["Stream:"].concat(Array.prototype.slice.call(arguments));console.log.apply(console,t)}},setStatus:function(t){this.status!==t&&(this.status=t,this.statusChanged.dispatch(this.status))},isConnected:function(){return this.socket.connected===!0},onSocketMessage:function(t){try{var e=JSON.parse(t.data)}catch(t){this.log("unable to parse streamed socket message as JSON.")}this.log("message",e),this.messageReceived.dispatch(e)},onSocketConnect:function(){this.log("connected"),this.emit("subscribe",{deck_id:this.options.deckID,user_id:SL.current_user.get("id"),slide_id:this.options.slideID}),this.setStatus(SL.helpers.StreamEditor.STATUS_CONNECTED)},onSocketDisconnect:function(){this.log("disconnected"),this.setStatus(SL.helpers.StreamEditor.STATUS_DISCONNECTED)},onSocketReconnectAttempt:function(){this.setStatus(SL.helpers.StreamEditor.STATUS_RECONNECTING),this.reconnecting.dispatch(this.socket.io.backoff.duration())},onSocketReconnectFailed:function(){this.log("reconnect failed"),this.setStatus(SL.helpers.StreamEditor.STATUS_RECONNECT_FAILED)},onSocketReconnect:function(){this.log("reconnected"),this.setStatus(SL.helpers.StreamEditor.STATUS_RECONNECTED)}}),SL.helpers.StreamEditor.STATUS_CONNECTED="connected",SL.helpers.StreamEditor.STATUS_RECONNECTED="reconnected",SL.helpers.StreamEditor.STATUS_RECONNECT_FAILED="reconnect_failed",SL.helpers.StreamEditor.STATUS_DISCONNECTED="disconnected",SL.helpers.StreamEditor.singleton=function(){return this._instance||(this._instance=new SL.helpers.StreamEditor({deckID:SLConfig.deck.id,slideID:SL.util.deck.getSlideID(Reveal.getCurrentSlide())})),this._instance},SL("helpers").StreamLive=Class.extend({init:function(t){this.options=$.extend({reveal:window.Reveal,showErrors:!0,subscriber:!0,publisher:!1,publisherID:Date.now()+"-"+Math.round(1e6*Math.random()),deck:SL.current_deck},t),this.options.deckReloadEndpoint||(this.options.deckReloadEndpoint=SL.endpoints.GET_DECK_JSON(this.options.deck.user.get("username"),this.options.deck.get("slug"))),this.ready=new signals.Signal,this.stateChanged=new signals.Signal,this.deckChanged=new signals.Signal,this.statusChanged=new signals.Signal,this.subscribersChanged=new signals.Signal,this.pointerChanged=new signals.Signal,this.timerStart=new signals.Signal,this.timerPause=new signals.Signal,this.timerStop=new signals.Signal,this.timerSync=new signals.Signal,this.timerRequestSync=new signals.Signal,this.socketIsDisconnected=!1,this.lastPublishedTime=0,this.debugMode=!!SL.util.getQuery().debug},connect:function(){this.options.publisher?this.setupPublisher():this.setupSubscriber()},setupPublisher:function(){this.publish=this.publish.bind(this),this.publishThrottled=this.publishThrottled.bind(this),this.publishable=!0,this.options.reveal.addEventListener("slidechanged",this.publishThrottled),this.options.reveal.addEventListener("fragmentshown",this.publishThrottled),this.options.reveal.addEventListener("fragmenthidden",this.publishThrottled),this.options.reveal.addEventListener("overviewshown",this.publish),this.options.reveal.addEventListener("overviewhidden",this.publish),this.options.reveal.addEventListener("paused",this.publish),this.options.reveal.addEventListener("resumed",this.publish),SL.deck.Animation.interactiveAnimationChanged.add(this.publishThrottled),$.ajax({url:SL.endpoints.DECK_STREAM(this.options.deck.get("id")),type:"POST",context:this}).done(function(t){this.publisherKey=t.publisher_key,t.active&&t.state?(this.log("found active stream"),this.setState(JSON.parse(t.state),!0),this.setupSocket(),this.bindInteractionEvents(),this.ready.dispatch()):(this.log("no active stream, publishing state"),this.publish(function(){this.setupSocket(),this.bindInteractionEvents(),this.ready.dispatch()}.bind(this)))}).error(function(t){this.showSetupError(t)})},setupSubscriber:function(){$.ajax({url:SL.endpoints.DECK_STREAM(this.options.deck.get("id")),type:"GET",context:this}).done(function(t){t.state?(this.log("found existing stream"),this.setStatus(SL.helpers.StreamLive.STATUS_NONE),this.setState(JSON.parse(t.state),!0),this.setupSocket(),this.ready.dispatch()):this.showWaitingForPresenter()}).error(function(){this.showWaitingForPresenter()})},setupSocket:function(){if(this.hideSetupError(),this.options.subscriber){var t=SL.config.STREAM_ENGINE_HOST+"/"+SL.config.STREAM_ENGINE_LIVE_NAMESPACE;this.log("socket attempting to connect to",t),this.socket=io.connect(t,{reconnectionDelayMax:1e4}),this.socket.on("connect",this.onSocketConnected.bind(this)),this.socket.on("connect_error",this.onSocketDisconnected.bind(this)),this.socket.on("disconnect",this.onSocketDisconnected.bind(this)),this.socket.on("reconnect_attempt",this.onSocketReconnectAttempt.bind(this)),this.socket.on("reconnect_failed",this.onSocketReconnectFailed.bind(this)),this.socket.on("message",this.onSocketMessage.bind(this)),this.socket.on("subscribers",this.onSocketSubscribersMessage.bind(this)),this.socket.on("broadcast",this.onSocketBroadcastMessage.bind(this))}},publish:function(t,e){if(clearTimeout(this.publishTimeout),this.publishable){this.lastPublishedTime=Date.now();var i={};if(this.options.reveal.isOverview()||(i=$.extend(i,this.options.reveal.getState()),i.animations=SL.deck.Animation.getSerializedInteractiveState()),i.publisher_id=this.options.publisherID,i.overview=!1,i=$.extend(i,e),this.socketIsDisconnected===!0)return this.publishAfterReconnect=!0,void this.log("publish stalled while disconnected");this.log("publish",i.publisher_id),$.ajax({url:SL.endpoints.DECK_STREAM(this.options.deck.get("id")),type:"PUT",data:{state:JSON.stringify(i)},success:t})}},publishThrottled:function(){clearTimeout(this.publishTimeout),Date.now()-this.lastPublishedTime>SL.helpers.StreamLive.STATE_CHANGE_THROTTLE?this.publish.apply(this,arguments):this.publishTimeout=setTimeout(this.publishThrottled,SL.helpers.StreamLive.STATE_CHANGE_THROTTLE)},emit:function(){this.log("emit",arguments),this.socket&&this.socket.emit.apply(this.socket,arguments)},broadcast:function(t){this.emit("broadcast",JSON.stringify(t))},log:function(){if(this.debugMode&&"function"==typeof console.log.apply){var t="Stream ("+(this.options.publisher?"publisher":"subscriber")+"):",e=[t].concat(Array.prototype.slice.call(arguments));console.log.apply(console,e)}},setState:function(t,e){this.publishable=!1,clearTimeout(this.publishTimeout),e&&$(".reveal").addClass("no-transition"),this.options.reveal.setState(t),this.stateChanged.dispatch(t),SL.deck.Animation.setSerializedInteractiveState(t.animations),setTimeout(function(){this.publishable=!0,e&&$(".reveal").removeClass("no-transition")}.bind(this),1)},setStatus:function(t){this.status!==t&&(this.status=t,this.statusChanged.dispatch(this.status))},getRetryStartTime:function(){return this.retryStartTime},isPublisher:function(){return this.options.publisher},showWaitingForPresenter:function(){this.retryStartTime=Date.now(),this.setStatus(SL.helpers.StreamLive.STATUS_WAITING_FOR_PUBLISHER),this.log("no existing stream, retrying in "+SL.helpers.StreamLive.CONNECTION_RETRY_INTERVAL/1e3+"s"),setTimeout(this.setupSubscriber.bind(this),SL.helpers.StreamLive.CONNECTION_RETRY_INTERVAL)},showSetupError:function(t){this.setupError||(t&&401===t.status?this.setupError=new SL.components.RetryNotification('<strong>Sorry, we\u2019re having trouble connecting.</strong><br>Please make sure you are still signed in.<br>If the problem persists, contact us <a href="http://help.slides.com" target="_blank">here</a>.',{type:"negative"}):this.setupError=new SL.components.RetryNotification('<strong>Sorry, we\u2019re having trouble connecting.</strong><br>If the problem persists, contact us <a href="http://help.slides.com" target="_blank">here</a>.',{type:"negative"}),this.setupError.disableCountdown(),this.setupError.destroyed.add(function(){this.setupError=null}.bind(this)),this.setupError.retryClicked.add(function(){this.setupError.destroy(),this.setupError=null,this.connect()}.bind(this)))},hideSetupError:function(){this.setupError&&this.setupError.hide()},showConnectionError:function(){this.disconnectTimeout=setTimeout(function(){this.connectionError||(this.connectionError=new SL.components.RetryNotification("Lost connection to server"),this.connectionError.startCountdown(0),this.connectionError.destroyed.add(function(){this.connectionError=null}.bind(this)),this.connectionError.retryClicked.add(function(){this.connectionError.startCountdown(0),this.socket.io.close(),this.socket.io.open()}.bind(this)))}.bind(this),1e4)},hideConnectionError:function(){clearTimeout(this.disconnectTimeout),this.connectionError&&this.connectionError.hide()},bindInteractionEvents:function(){var t='.reveal .slides .sl-block[data-block-type="video"][data-block-id], .reveal .slides .sl-block[data-block-type="audio"][data-block-id]';$(t).each(function(t,e){var i=e.querySelector("video, audio");if(i&&!i.hasAttribute("autoplay")&&!i.hasAttribute("data-autoplay")){var n=e.getAttribute("data-block-id");i.addEventListener("play",this.broadcastMediaEvent.bind(this,"media:play",n,i)),i.addEventListener("pause",this.broadcastMediaEvent.bind(this,"media:pause",n,i)),i.addEventListener("seeked",this.broadcastMediaEvent.bind(this,"media:seeked",n,i))}}.bind(this))},broadcastMediaEvent:function(t,e,i){(!this.preventMediaEventsUntil||Date.now()>this.preventMediaEventsUntil)&&this.broadcast({type:t,blockID:e,currentTime:i.currentTime})},onSocketMessage:function(t){try{var e=JSON.parse(t.data);"deck_changed"===e.type?this.onSocketDeckChanged():e.publisher_id!=this.options.publisherID&&(this.log("sync","from: "+e.publisher_id,"to: "+this.options.publisherID),this.setState(e))}catch(t){this.log("unable to parse streamed deck state as JSON.")}this.setStatus(SL.helpers.StreamLive.STATUS_NONE)},onSocketDeckChanged:function(){this.log("deck changed"),this.reloadDeckXHR&&this.reloadDeckXHR.abort(),this.reloadDeckXHR=SL.util.deck.reloadDeck(this.options.deckReloadEndpoint,this.options.deck).done(function(t){t&&t.data&&(this.bindInteractionEvents(),this.deckChanged.dispatch())}.bind(this)).always(function(){this.reloadDeckXHR=null}.bind(this))},onSocketSubscribersMessage:function(t){this.subscribersChanged.dispatch(t.subscribers)},onSocketBroadcastMessage:function(t){try{var e=JSON.parse(t.data)}catch(t){this.log("unable to parse streamed socket message as JSON.")}switch(this.log("broadcast",e),e.type){case"live:pointer":this.pointerChanged.dispatch(e);break;case"timer:start":this.timerStart.dispatch(e);break;case"timer:pause":this.timerPause.dispatch(e);break;case"timer:stop":this.timerStop.dispatch(e);break;case"timer:sync":this.timerSync.dispatch(e);break;case"timer:request-sync":this.timerRequestSync.dispatch(e);break;case"media:play":case"media:pause":case"media:seeked":this.onSocketMediaInteraction(e)}},onSocketConnected:function(){this.log("socket connected"),this.socket.emit("subscribe",{deck_id:this.options.deck.get("id"),publisher:this.options.publisher,publisher_key:this.publisherKey}),this.socketIsDisconnected===!0&&(this.socketIsDisconnected=!1,this.log("socket connection regained"),this.setStatus(SL.helpers.StreamLive.STATUS_NONE),this.publishAfterReconnect===!0&&(this.publishAfterReconnect=!1,this.log("publishing stalled state"),this.publish())),this.hideConnectionError()},onSocketReconnectAttempt:function(){this.connectionError&&this.connectionError.startCountdown(this.socket.io.backoff.duration())},onSocketReconnectFailed:function(){this.connectionError&&this.connectionError.disableCountdown()},onSocketDisconnected:function(){this.socketIsDisconnected===!1&&(this.socketIsDisconnected=!0,this.log("socket connection lost"),this.setStatus(SL.helpers.StreamLive.STATUS_CONNECTION_LOST),this.options.showErrors&&this.showConnectionError())},onSocketMediaInteraction:function(t){if(t&&t.type){var e=$('.reveal .slides .sl-block[data-block-id="'+t.blockID+'"]').find("video, audio").get(0);e&&(this.preventMediaEventsUntil=Date.now()+3e3,"media:play"===t.type?(e.play(),"number"!=typeof t.currentTime||isNaN(t.currentTime)||(e.currentTime=t.currentTime)):"media:pause"===t.type?e.pause():"media:seeked"===t.type&&(e.currentTime=t.currentTime))}}}),SL.helpers.StreamLive.CONNECTION_RETRY_INTERVAL=1e4,SL.helpers.StreamLive.STATE_CHANGE_THROTTLE=200,SL.helpers.StreamLive.STATUS_NONE="",SL.helpers.StreamLive.STATUS_CONNECTION_LOST="connection_lost",SL.helpers.StreamLive.STATUS_WAITING_FOR_PUBLISHER="waiting_for_publisher",SL.helpers.ThemeController={paint:function(t,e){e=e||{};var i=$(".reveal-viewport");if(0===i.length||"undefined"==typeof window.Reveal)return!1;if(this.cleanup(),i.addClass("theme-font-"+t.get("font")),i.addClass("theme-color-"+t.get("color")),Reveal.configure($.extend({width:t.get("width"),height:t.get("height"),center:t.get("center"),rolling_links:t.get("rolling_links"),transition:t.get("transition"),backgroundTransition:t.get("background_transition")},e)),t.get("html")){var n=$("#theme-html-output");n.length?n.html(t.get("html")):$(".reveal").append('<div id="theme-html-output">'+t.get("html")+"</div>")}else $("#theme-html-output").remove();if("string"==typeof e.globalCSS)if(e.globalCSS.length){var s=$("#global-css-output");s.length?s.html(e.globalCSS):$("head").append('<style id="global-css-output">'+e.globalCSS+"</style>")}else $("#global-css-output").remove();if(t.get("css")){var o=$("#theme-css-output");o.length?o.html(t.get("css")):$("head").append('<style id="theme-css-output">'+t.get("css")+"</style>")}else $("#theme-css-output").remove();if(e.js!==!1)if(t.get("js")){var a=$("#theme-js-output");a.text()!==t.get("js")&&(a.remove(),$("body").append(["<",'script id="theme-js-output">',t.get("js"),"<","/script",">"].join("")))}else $("#theme-js-output").remove();SL.util.deck.sortInjectedStyles(),SL.fonts.loadDeckFont(t.get("font"))},cleanup:function(){var t=$(".reveal-viewport"),e=$(".reveal");t.attr("class",t.attr("class").replace(/theme\-(font|color)\-([a-z0-9-])*/gi,"")),SL.config.THEME_TRANSITIONS.forEach(function(t){e.removeClass(t.id)})}},SL.popup={items:[],singletons:[],open:function(t,e){for(var i,n=0;n<SL.popup.singletons.length;n++)if(SL.popup.singletons[n].factory===t){i=SL.popup.singletons[n].instance;break}return i||(i=new t(e),i.isSingleton()&&SL.popup.singletons.push({factory:t,instance:i})),i.open(e),SL.popup.items.push({instance:i,factory:t}),$("html").addClass("popup-open"),i},openOne:function(t,e){for(var i=0;i<SL.popup.items.length;i++)if(t===SL.popup.items[i].factory)return SL.popup.items[i].instance;return this.open(t,e)},close:function(t){SL.popup.items.concat().forEach(function(e){t&&t!==e.factory||e.instance.close(!0)})},isOpen:function(t){for(var e=0;e<SL.popup.items.length;e++)if(!t||t===SL.popup.items[e].factory)return!0;return!1},unregister:function(t){for(var e=0;e<SL.popup.items.length;e++)SL.popup.items[e].instance===t&&(removedValue=SL.popup.items.splice(e,1),e--);0===SL.popup.items.length&&$("html").removeClass("popup-open")}},SL("components.popup").Popup=Class.extend({RELATIVE_WINDOW_PADDING:.01,FIXED_WINDOW_PADDING:5,USE_ABSOLUTE_POSITIONING:SL.util.device.IS_PHONE||SL.util.device.IS_TABLET,init:function(t){this.options=$.extend({title:"",titleItem:"",header:!0,headerActions:[{label:"Close",className:"grey",callback:this.close.bind(this)}],width:"auto",height:"auto",singleton:!1,skipIntro:!1,closeOnEscape:!0,closeOnClickOutside:!0},t),this.closed=new signals.Signal,this.render(),this.bind(),this.layout()},render:function(){this.domElement=$('<div class="sl-popup" data-id="'+this.TYPE+'">'),this.domElement.appendTo(document.body),this.backgroundElement=$('<div class="sl-popup-background">'),this.backgroundElement.appendTo(this.domElement),this.innerElement=$('<div class="sl-popup-inner">'),this.innerElement.appendTo(this.domElement),this.options.skipIntro&&this.domElement.addClass("skip-intro"),this.options.header&&(this.renderHeader(),this.renderHeaderActions()),this.bodyElement=$('<div class="sl-popup-body">'),this.bodyElement.appendTo(this.innerElement)},renderHeader:function(){this.headerElement=$(['<header class="sl-popup-header">','<h3 class="sl-popup-header-title"></h3>',"</header>"].join("")),this.headerElement.appendTo(this.innerElement),this.headerTitleElement=this.headerElement.find(".sl-popup-header-title"),this.refreshTitle()},renderHeaderActions:function(){var t=this.options.headerActions;this.options.additionalHeaderActions&&(t=this.options.additionalHeaderActions.concat(t)),t&&t.length&&(this.headerActionsElement?this.headerActionsElement.empty():this.headerActionsElement=$('<div class="sl-popup-header-actions">').appendTo(this.headerElement),t.forEach(function(t){if("divider"===t.type)$('<div class="divider"></div>').appendTo(this.headerActionsElement);else{var e=$('<button class="button l '+t.className+'">'+(t.label||"")+"</button>").appendTo(this.headerActionsElement).on("vclick",function(e){t.callback(e),e.preventDefault()});t.tooltip&&e.attr("data-tooltip",t.tooltip)}}.bind(this)))},replaceAdditionalHeaderActions:function(t){this.options.additionalHeaderActions=t,this.renderHeaderActions()},refreshTitle:function(){if(this.headerTitleElement.text(this.options.title),this.options.titleItem){var t=this.headerTitleElement.find(".sl-popup-header-title-item");0===t.length&&(t=$('<span class="sl-popup-header-title-item"></span>').appendTo(this.headerTitleElement)),t.text(this.options.titleItem)}else this.headerTitleElement.find(".sl-popup-header-title-item").remove()},bind:function(){this.onKeyDown=this.onKeyDown.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.onBackgroundMouseDown=this.onBackgroundMouseDown.bind(this),this.onBackgroundMouseUp=this.onBackgroundMouseUp.bind(this),this.domElement.on("vmousedown",this.onBackgroundMouseDown),this.domElement.on("vmouseup",this.onBackgroundMouseUp)},layout:function(){this.innerElement.css({width:this.options.width,height:this.options.height});var t=window.innerWidth,e=window.innerHeight,i=t*this.RELATIVE_WINDOW_PADDING+this.FIXED_WINDOW_PADDING,n=e*this.RELATIVE_WINDOW_PADDING+this.FIXED_WINDOW_PADDING;if(this.options.height){var s=this.getHeaderHeight();this.headerElement&&"number"==typeof this.options.height?this.bodyElement.css("height",this.options.height-s):this.bodyElement.css("height","auto"),this.bodyElement.css("max-height",e-s-2*n)}if(this.headerElement){var o=this.headerElement.width(),a=this.headerActionsElement.outerWidth();this.headerTitleElement.css("max-width",o-a-30)}if(this.USE_ABSOLUTE_POSITIONING){var r=$(window);this.domElement.css({position:"absolute",height:Math.max($(window).height(),$(document).height())});var l=Math.round(r.scrollTop()+(r.height()-this.innerElement.outerHeight())/2),d=Math.round(r.scrollLeft()+(r.width()-this.innerElement.outerWidth())/2);l=Math.max(l,n),d=Math.max(d,i),this.innerElement.css({position:"absolute",transform:"none",top:l,left:d,maxWidth:Math.round(r.width()-2*i),maxHeight:Math.round(r.height()-2*n)})}},getHeaderHeight:function(){return this.headerElement?this.headerElement.outerHeight():0},open:function(t){this.domElement.appendTo(document.body),this.options=$.extend(this.options,t),SL.keyboard.keydown(this.onKeyDown),$(window).on("resize",this.onWindowResize),setTimeout(function(){this.domElement.addClass("visible"),this.afterOpen()}.bind(this),1)},afterOpen:function(){},close:function(t){t?this.closeConfirmed():this.checkUnsavedChanges(this.closeConfirmed.bind(this))},closeConfirmed:function(){SL.keyboard.release(this.onKeyDown),$(window).off("resize",this.onWindowResize),this.domElement.removeClass("visible"),SL.popup.unregister(this),this.domElement.detach(),this.closed.dispatch(),this.isSingleton()||this.destroy()},checkUnsavedChanges:function(t){t()},isSingleton:function(){return this.options.singleton},onBackgroundMouseDown:function(t){this.mouseDownTarget=t.target},onBackgroundMouseUp:function(t){t.target===this.mouseDownTarget&&$(t.target).is(this.domElement)&&(this.options.closeOnClickOutside&&this.close(),t.preventDefault())},onWindowResize:function(){this.layout()},onKeyDown:function(t){return 27!==t.keyCode||(this.options.closeOnEscape&&this.close(),!1)},destroy:function(){SL.popup.unregister(this),SL.keyboard.release(this.onKeyDown),$(window).off("resize",this.onWindowResize),this.options=null,this.closed.dispose(),this.domElement.remove()}}),SL("components.popup").CodeEditor=SL.components.popup.Popup.extend({TYPE:"code-editor",init:function(t){this._super($.extend({title:"Edit",width:1200,height:750,skipIntro:!0,headerActions:[{label:"Cancel",className:"outline",callback:this.close.bind(this)},{label:"Save"+SL.util.getKeyboardShortcutName("Enter",{meta:!0,casesensitive:!0,span:!0}),className:"positive",callback:this.saveAndClose.bind(this)}]},t)),this.saved=new signals.Signal},render:function(){this._super(),this.bodyElement.empty();try{this.editor=SL.util.createCodeEditor(this.bodyElement.get(0),{mode:this.options.mode})}catch(t){console.log("An error occurred while initializing the code editor.")}this.editor.setValue(this.options.value||"")},afterOpen:function(){this._super(),this.editor.focus()},saveAndClose:function(){this.saved.dispatch(this.getValue()),this.close(!0)},checkUnsavedChanges:function(t){this.getValue()===this.options.value||this.cancelPrompt?t():(this.cancelPrompt=SL.prompt({title:"Discard unsaved changes?",type:"select",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Discard</h3>",selected:!0,className:"negative",callback:t}]}),this.cancelPrompt.destroyed.add(function(){this.cancelPrompt=null}.bind(this)))},getValue:function(){return this.editor.getValue()},onKeyDown:function(t){return(t.metaKey||t.ctrlKey)&&13===t.keyCode?(this.options.closeOnEscape&&this.saveAndClose(),!1):this._super.apply(this,arguments)},destroy:function(){this.editor=null,this.saved&&(this.saved.dispose(),this.saved=null),this._super()}}),SL("components.popup").CustomFonts=SL.components.popup.Popup.extend({TYPE:"custom-fonts",init:function(t){this._super($.extend({title:"Load custom fonts",deck:null,theme:null,width:600,closeOnClickOutside:!0,headerActions:[{label:"Cancel",className:"outline",callback:this.close.bind(this)},{label:"Save"+SL.util.getKeyboardShortcutName("Enter",{meta:!0,casesensitive:!0,span:!0}),className:"positive",callback:this.onSaveClicked.bind(this)}]},t)),this.loadGoogleFontList()},render:function(){return this._super(),this.bodyElement.append($(['<div class="sl-form">','<div class="unit typekit-settings">','<h4 class="form-label">Typekit</h4>','<p class="unit-description">Specify a <a href="https://typekit.com/" target="_blank">Typekit</a> kit ID to load for this presentation.</p>','<input type="text" maxlength="255" placeholder="Kit ID">',"</div>",'<div class="unit google-settings">','<h4 class="form-label">Google Fonts</h4>','<p class="unit-description">A list of comma separated font families to load from <a href="https://fonts.google.com/" target="_blank">Google Fonts</a>. Font weights can be indicated with a colon after the font family, for example: Open Sans:300,700</p>','<input type="text" maxlength="255" placeholder="Droid Sans, Droid Serif:bold">','<p class="google-status"></p>',"</div>","<div>"].join(""))),this.options.deck||this.options.theme?(this.googleStatus=this.bodyElement.find(".google-settings .google-status"),this.typekitInput=this.bodyElement.find(".typekit-settings input"),this.googleInput=this.bodyElement.find(".google-settings input"),this.googleInput.on("input",this.onGoogleInput.bind(this)),this.options.theme?(this.typekitInput.val(this.options.theme.get("font_typekit")||""),this.googleInput.val(this.options.theme.get("font_google")||"")):(this.typekitInput.val(this.options.deck.get("font_typekit")||""),this.googleInput.val(this.options.deck.get("font_google")||"")),void this.validateGoogleFonts()):void this.bodyElement.html("Configuration error. Missing deck/theme model.")},loadGoogleFontList:function(){window.SLGoogleFontList?this.setupGoogleFontAutocomplete():$.get(SL.config.GOOGLE_FONTS_LIST).done(function(t){window.SLGoogleFontList=t.items.map(function(t){return{family:t.family,variants:t.variants.join(", ")}}),this.setupGoogleFontAutocomplete()}.bind(this))},searchGoogleFontList:function(t){var e=[];if(t&&t.length>0){for(var i=window.SLGoogleFontList,n=0,s=i.length;n<s;n++){var o=i[n];o.family.search(new RegExp(t,"i"))!==-1&&e.push({value:o.family,label:'<div class="value">'+o.family+'</div><div class="description">'+o.variants+"</div>"})}e=e.slice(0,10)}return Promise.resolve(e)},setupGoogleFontAutocomplete:function(){this.googleFontAutocomplete=new SL.components.form.Autocomplete(this.googleInput,this.searchGoogleFontList.bind(this),{className:"light-grey",offsetY:1}),this.googleFontAutocomplete.confirmed.add(this.onGoogleInput.bind(this))},onSaveClicked:function(t){this.saveLoader||($(t.target).addClass("ladda-button").attr({"data-style":"expand-right","data-spinner-size":"26"}),this.saveLoader=Ladda.create(t.target)),this.saveLoader.start(),this.saveAndClose()},saveAndClose:function(){var t=this.typekitInput.val()||"",e=this.googleInput.val()||"";this.options.theme?(this.saveLoader.stop(),this.options.theme.setAll({font_typekit:t,font_google:e}),this.close(!0)):$.ajax({url:SL.endpoints.UPDATE_DECK(this.options.deck.get("id")),type:"PUT",context:this,data:{deck:{font_typekit:t,font_google:e}}}).done(function(){this.options.deck.setAll({font_typekit:t,font_google:e}),t.length&&SL.fonts.loadTypekitFont(t),e.length&&SL.fonts.loadGoogleFont(e),this.close(!0)}).fail(function(){SL.notify("An error occured while saving","negative")}).always(function(){this.saveLoader.stop()})},validateGoogleFonts:function(){var t=SL.fonts.parseGoogleFontFamilies(this.googleInput.val()||""),e=t.length+" "+SL.util.string.pluralize("font","s",t.length>1)+": ";e+=t.map(function(t){return'<span class="google-status-item">'+t+"</span>"}).join(""),this.googleStatus.html(e),this.googleStatus.toggleClass("visible",t.length>0)},destroy:function(){this.saveLoader&&this.saveLoader.remove(),this._super()},onGoogleInput:function(){this.validateGoogleFonts()},onKeyDown:function(t){return(t.metaKey||t.ctrlKey)&&13===t.keyCode?(this.options.closeOnEscape&&this.saveAndClose(),!1):this._super.apply(this,arguments)}}),SL("components.popup").DeckTemplates=SL.components.popup.Popup.extend({TYPE:"deck-templates",init:function(t){this.pageData=[{label:"Templates",render:this.renderTemplatesPage.bind(this)},{label:"Your Decks",render:this.renderDecksPage.bind(this),postProcessListItem:function(t){SL.view&&"function"==typeof SL.view.hasOwnDecks&&SL.view.hasOwnDecks()===!1&&t.addClass("disabled")}}],this._super($.extend({title:"New Deck",titleItem:"Select Template",width:1010,height:820},t))},render:function(){this._super.apply(this,arguments),this.bodyElement.addClass("has-sidebar"),this.sidebar=$('<div class="sl-popup-sidebar"></div>').appendTo(this.bodyElement),this.content=$('<div class="sl-popup-content"></div>').appendTo(this.bodyElement),this.pageData.forEach(this.renderPage,this)},renderPage:function(t){t.sidebarElement=$('<button class="sl-popup-sidebar-button button">'+t.label+"</button>"),t.sidebarElement.appendTo(this.sidebar),t.sidebarElement.on("vclick",this.selectPage.bind(this,t)),t.contentElement=t.render(),t.contentElement.appendTo(this.content),t.contentElement.hide(),"function"==typeof t.postProcessListItem&&t.postProcessListItem(t.sidebarElement)},renderTemplatesPage:function(){var t=$('<div class="sl-popup-content-page"><div class="content-placeholder">Loading templates...</div></div>'),e=new SL.collections.Decks(null,null,{list:SL.endpoints.DECK_TEMPLATES_LIST()});return e.load().then(function(){t.empty(),this.renderBlankWhiteDeckTemplate().appendTo(t),this.renderBlankBlackDeckTemplate().appendTo(t),e.forEach(function(e){this.renderDeck(e,{metadata:!1}).appendTo(t)},this)}.bind(this),function(){t.html("An error occurred while loading templates.")}),t},renderDecksPage:function(){var t=$('<div class="sl-popup-content-page"><div class="content-placeholder">Loading decks...</div></div>'),e=new SL.collections.Decks(null,null,{list:SL.endpoints.DECK_LIST()});return e.load().then(function(){t.empty(),e.isEmpty()?t.html('<div class="content-placeholder">You don\'t have any decks yet.</div>'):e.forEach(function(e){this.renderDeck(e).appendTo(t)},this)}.bind(this),function(){t.html("An error occurred while loading templates.")}),t},renderBlankWhiteDeckTemplate:function(){var t=new SL.models.Deck({title:"Empty White Deck",thumbnail_url:"https://static.slid.es/images/deck-templates/blank-white-template.png",user:{}}),e=SL.deckthumbs.create(t,{preview:!1,link:!1,context:"template-blank"});return e.on("vclick",function(){SL.helpers.PageLoader.show({message:"Creating deck..."}),window.location=SL.routes.DECK_NEW(SL.current_user.get("username"))}),e},renderBlankBlackDeckTemplate:function(){var t=new SL.models.Deck({title:"Empty Black Deck",thumbnail_url:"https://static.slid.es/images/deck-templates/blank-black-template.png",user:{}}),e=SL.deckthumbs.create(t,{preview:!1,link:!1,context:"template-blank"});return e.on("vclick",function(){SL.helpers.PageLoader.show({message:"Creating deck..."}),window.location=SL.routes.DECK_NEW(SL.current_user.get("username"))+"?theme_color=black-blue"}),e},renderDeck:function(t){var e=SL.deckthumbs.create(t,{preview:!0,link:!1,context:"template"});return e.find(".select-button").on("vclick",function(e){e.preventDefault(),e.stopPropagation(),this.selectDeck(t)}.bind(this)),e.on("vclick",this.onDeckClicked.bind(this,t,e)),e},selectPage:function(t){SL.deckthumbs.stopAllDeckPreviews(),this.sidebar.find(".selected").removeClass("selected"),this.content.find(".sl-popup-content-page").hide(),t.sidebarElement.addClass("selected"),t.contentElement.show()},open:function(){this._super.apply(this,arguments),this.selectPage(this.pageData[0])},selectDeck:function(t){SL.helpers.PageLoader.show({message:"Creating deck..."}),$.ajax({type:"POST",url:SL.endpoints.FORK_DECK(t.get("id")),context:this}).done(function(t){window.location=SL.routes.DECK_EDIT(SL.current_user.get("username"),t.deck.slug)}).fail(function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative"),SL.helpers.PageLoader.hide()})},destroy:function(){SL.deckthumbs.stopAllDeckPreviews(),this._super.apply(this,arguments)},onDeckClicked:function(t,e,i){if(0===$(i.target).closest(".button").length)return this.selectDeck(t),!1}}),SL("components.popup").DeckOutdated=SL.components.popup.Popup.extend({TYPE:"deck-outdated",init:function(t){this._super($.extend({title:"Newer version available",width:500,closeOnClickOutside:!1,headerActions:[{label:"Ignore",className:"outline",callback:this.close.bind(this)},{label:"Reload",className:"positive",callback:this.onReloadClicked.bind(this)}]},t))},render:function(){this._super(),this.bodyElement.html(["<p>A more recent version of this presentation is available on the server. This can happen when the presentation is saved from another browser or device.</p>","<p>We recommend reloading the page to get the latest version. If you're sure your local changes are the latest, please ignore this message.</p>"].join(""))},onReloadClicked:function(){window.location.reload()},destroy:function(){this._super()}}),SL("components.popup").EditSlideHTML=SL.components.popup.CodeEditor.extend({TYPE:"edit-slide-html",init:function(t){t.value=SL.util.html.indent(SL.editor.controllers.Serialize.getSlideAsString(t.slide,{inner:!0,lazy:!1,exclude:".math-output"})),this._super(t)}}),SL("components.popup").InsertSnippet=SL.components.popup.Popup.extend({TYPE:"insert-snippet",init:function(t){this._super($.extend({title:"Insert",
titleItem:'"'+t.snippet.get("title")+'"',width:500,headerActions:[{label:"Cancel",className:"outline",callback:this.close.bind(this)},{label:"Insert",className:"positive",callback:this.insertAndClose.bind(this)}]},t)),this.snippetInserted=new signals.Signal},render:function(){this._super(),this.variablesElement=$('<div class="variables sl-form"></div>'),this.variablesElement.appendTo(this.bodyElement),this.variables=this.options.snippet.getTemplateVariables(),this.variables.forEach(function(t){var e=$(['<div class="unit">',"<label>"+t.label+"</label>",'<input type="text" value="'+t.defaultValue+'">',"</div>"].join("")).appendTo(this.variablesElement);e.find("input").data("variable",t),"image"===t.inputType?e.prepend('<a class="browse-for-image" href="#">Select Image</a>'):"video"===t.inputType&&e.prepend('<a class="browse-for-video" href="#">Select Video</a>')}.bind(this)),this.variablesElement.find("input").first().focus().select()},bind:function(){this._super.apply(this,arguments),this.domElement.on("vclick",".browse-for-image, .browse-for-video",function(t){t.preventDefault();var e,i=$(t.target).closest(".unit").find("input");e=$(t.currentTarget).hasClass("browse-for-video")?SL.popup.open(SL.components.medialibrary.MediaLibrary,{select:SL.models.Media.VIDEO}):SL.popup.open(SL.components.medialibrary.MediaLibrary,{select:SL.models.Media.IMAGE}),e.selected.addOnce(function(t){t.isUploaded()?i.val(t.get("url")):t.uploadCompleted.add(function(){i.val(t.get("url"))}.bind(this))}.bind(this))}.bind(this))},insertAndClose:function(){this.variablesElement.find("input").each(function(t,e){e=$(e),e.data("variable").value=e.val()}),this.snippetInserted.dispatch(this.options.snippet.templatize(this.variables)),this.close()},onKeyDown:function(t){return 13===t.keyCode?(this.insertAndClose(),!1):this._super(t)},destroy:function(){this.snippetInserted.dispose(),this._super()}}),SL("components.popup").PreviewMedia=SL.components.popup.Popup.extend({TYPE:"preview-media",init:function(t){this._super($.extend({title:"Preview",width:640,height:360,headerActions:[{className:"grey icon i-x",callback:this.close.bind(this)}],mediaType:"image",mediaURL:null,mediaWidth:null,mediaHeight:null},t)),setTimeout(this.load.bind(this),1)},render:function(){this._super(),this.mediaPreloader=$(['<div class="media-preloader hidden">','<div class="spinner centered" data-spinner-color="#333">',"</div>","</div>"].join("")).appendTo(this.bodyElement),SL.util.html.generateSpinners()},layout:function(){var t=this.options.mediaWidth,e=this.options.mediaHeight;if(this.bodyElement.hasClass("loaded-media")&&(t=this.mediaElement.prop("naturalWidth")||this.mediaElement.prop("videoWidth"),e=this.mediaElement.prop("naturalHeight")||this.mediaElement.prop("videoHeight")),t&&e){var i=12,n=this.getHeaderHeight(),s=.96*window.innerWidth-i,o=.96*window.innerHeight-n-i,a=s/o,r=t/e;r>a?(this.options.width=Math.min(s,t),this.options.height=this.options.width/r):(this.options.height=Math.min(o,e),this.options.width=this.options.height*r),this.options.width=Math.round(this.options.width)+i,this.options.height=Math.round(this.options.height)+n+i}this._super.apply(this,arguments)},load:function(){"image"===this.options.mediaType?this.loadImage():"video"===this.options.mediaType?this.loadVideo():"iframe"===this.options.mediaType?this.loadIframe():SL.notify('Unable to preview media of type "'+this.options.mediaType+'"')},loadImage:function(){this.mediaElement=$("<img>"),this.mediaElement.appendTo(this.bodyElement),this.mediaElement.on("load",this.onMediaLoaded.bind(this)),this.mediaElement.on("error",this.onMediaLoadError.bind(this)),this.mediaElement.attr("src",this.options.mediaURL)},loadVideo:function(){this.mediaElement=$("<video controls playsinline autoplay>"),this.mediaElement.appendTo(this.bodyElement),this.mediaElement.on("canplay",this.onMediaLoaded.bind(this)),this.mediaElement.on("error",this.onMediaLoadError.bind(this)),this.mediaElement.attr("src",this.options.mediaURL+"?1")},loadIframe:function(){this.mediaElement=$("<iframe>"),this.mediaElement.appendTo(this.bodyElement),this.mediaElement.on("load",this.onMediaLoaded.bind(this)),this.mediaElement.on("error",this.onMediaLoadError.bind(this)),this.mediaElement.attr("src",this.options.mediaURL)},onMediaLoaded:function(){this.bodyElement.addClass("loaded-media"),this.mediaElement.is("video")&&this.mediaElement.get(0).play(),this.mediaPreloader.remove(),this.layout()},onMediaLoadError:function(){this.mediaPreloader.remove()},destroy:function(){this.mediaElement&&(this.mediaElement.off(),this.mediaElement.attr("src",""),this.mediaElement.remove()),this._super()}}),SL("components.popup").Revision=SL.components.popup.Popup.extend({TYPE:"revision",init:function(t){var e=[{label:"Open in new tab",className:"outline",callback:this.onOpenExternalClicked.bind(this)}];SL.editor.Editor.VERSION>1&&e.push({label:"Restore current slide",className:"grey",callback:this.onRestoreSlideClicked.bind(this)}),e.push({label:"Restore deck",className:"grey",callback:this.onRestoreClicked.bind(this)}),e.push({label:"Close",className:"grey",callback:this.close.bind(this)}),this._super($.extend({revisionURL:null,revisionTimeAgo:null,title:"Revision",titleItem:"from "+t.revisionTimeAgo,width:1080,height:840,headerActions:e},t)),this.restoreRequested=new signals.Signal,this.externalRequested=new signals.Signal},render:function(){this._super(),this.bodyElement.html(['<div class="spinner centered"></div>','<div class="deck"></div>'].join("")),this.bodyElement.addClass("loading"),SL.util.html.generateSpinners(),this.iframe=$("<iframe>",{src:this.options.revisionURL,load:function(){this.bodyElement.removeClass("loading")}.bind(this)}),this.iframe.appendTo(this.bodyElement.find(".deck"))},onRestoreClicked:function(t){this.restoreRequested.dispatch(t)},onRestoreSlideClicked:function(t){if(this.iframe){var e=this.iframe.get(0).contentWindow;if(e&&e.Reveal){var i=e.Reveal.getCurrentSlide(),n=i.outerHTML,s=$('.reveal .slides section[data-id="'+i.getAttribute("data-id")+'"]');1===s.length?SL.prompt({anchor:$(t.currentTarget),title:SL.locale.get("SLIDE_RESTORE_CONFIRM"),type:"select",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Add as new slide</h3>",callback:function(){SL.editor.controllers.Markup.addHorizontalSlide($(n).attr("data-id","").get(0).outerHTML),SL.notify("Slide was restored","white")}},{html:"<h3>Yes, restore this slide</h3>",className:"positive",selected:!0,callback:function(){var t=SL.editor.controllers.Markup.replaceSlide(s,n);SL.util.deck.navigateToSlide(t.get(0)),SL.notify("Slide was restored","white")}}]}):(SL.editor.controllers.Markup.addHorizontalSlide($(n).attr("data-id","").get(0).outerHTML),SL.notify("Slide was restored","white"))}}},onOpenExternalClicked:function(t){this.externalRequested.dispatch(t)},destroy:function(){this.bodyElement.find(".deck iframe").attr("src",""),this.bodyElement.find(".deck").empty(),this.restoreRequested.dispose(),this.externalRequested.dispose(),this._super()}}),SL("components.popup").SessionExpired=SL.components.popup.Popup.extend({TYPE:"session-expired",init:function(t){this._super($.extend({title:"Session expired",width:500,closeOnEscape:!1,closeOnClickOutside:!1,headerActions:[{label:"Ignore",className:"outline negative",callback:this.close.bind(this)},{label:"Retry",className:"positive",callback:this.onRetryClicked.bind(this)}]},t))},render:function(){this._super(),this.bodyElement.html(["<p>You are no longer signed in to Slides. This can happen when you leave the page idle for too long, log out in a different tab or go offline. To continue please:</p>","<ol>",'<li><a href="'+SL.routes.SIGN_IN+'" target="_blank" style="text-decoration: underline;">Sign in</a> to Slides from another browser tab.</li>',"<li>Come back to this tab and press the 'Retry' button.</li>","</ol>"].join(""))},onRetryClicked:function(){SL.editor&&1===SL.editor.Editor.VERSION?SL.view.checkLogin(!0):SL.session.check()},destroy:function(){this._super()}}),SL("components.collab").Collaboration=Class.extend({init:function(t){this.options=$.extend({container:document.body,editor:!1,fixed:!1,coverPage:!1,autofocusComment:!0},t),this.loaded=new signals.Signal,this.enabled=new signals.Signal,this.expanded=new signals.Signal,this.collapsed=new signals.Signal,this.flags={expanded:!1,enabled:!1,connected:!1},this.commentsWhileHidden=[],this.commentsWhileCollapsed=[],this.bind(),this.render(),this.setEnabled(!!SLConfig.deck.collaborative),this.options.fixed&&(SL.util.skipCSSTransitions($(this.domElement),1),this.domElement.addClass("fixed"),this.expand())},bind:function(){this.onKeyDown=this.onKeyDown.bind(this),this.onSlideChanged=this.onSlideChanged.bind(this),this.onStreamMessage=this.onStreamMessage.bind(this),this.onStreamStatusChanged=this.onStreamStatusChanged.bind(this),this.onSocketReconnecting=this.onSocketReconnecting.bind(this);var t=$(".reveal .slides section:not(.stack)").length,e=1e3*Math.ceil(t/4);this.onStreamDeckContentChanged=$.throttle(this.onStreamDeckContentChanged,e)},render:function(){this.domElement=$('<div class="sl-collab loading">'),this.domElement.appendTo(this.options.container),this.options.coverPage&&!this.options.fixed&&(this.coverElement=$('<div class="sl-collab-cover">'),this.coverElement.on("vclick",this.collapse.bind(this)),this.coverElement.appendTo(this.domElement)),this.innerElement=$('<div class="sl-collab-inner">'),this.innerElement.appendTo(this.domElement),this.bodyElement=$('<div class="sl-collab-body">'),this.bodyElement.appendTo(this.innerElement),this.overlayElement=$('<div class="sl-collab-overlay">'),this.overlayElement.appendTo(this.innerElement),this.overlayContent=$('<div class="sl-collab-overlay-inner">'),this.overlayContent.appendTo(this.overlayElement),this.menu=new SL.components.collab.Menu(this),this.menu.appendTo(this.domElement)},load:function(){this.usersCollection||(this.showLoadingOverlay(),this.usersCollection=new SL.collections.collab.DeckUsers,this.usersCollection.load().then(this.afterLoad.bind(this),function(){this.usersCollection=null,this.showErrorOverlay("Failed to load collaborators",this.load.bind(this))}.bind(this)))},afterLoad:function(){return this.usersCollection.isEmpty()?void this.showErrorOverlay("No collaborators found for this deck."):(this.usersCollection.replaced.add(function(){this.cachedCurrentDeckUser=null}.bind(this)),void this.connect())},connect:function(){if(this.hasBoundStreamEvents||(this.hasBoundStreamEvents=!0,SL.helpers.StreamEditor.singleton().statusChanged.add(this.onStreamStatusChanged),SL.helpers.StreamEditor.singleton().messageReceived.add(this.onStreamMessage),SL.helpers.StreamEditor.singleton().reconnecting.add(this.onSocketReconnecting)),!this.isConnected())return this.showLoadingOverlay(),SL.helpers.StreamEditor.singleton().connect().then(function(){},function(){this.onSocketConnectionFailed()}.bind(this))},afterConnect:function(){this.isConnected()||(this.flags.connected=!0,this.renderContent(),SL.activity.register(SL.config.COLLABORATION_IDLE_TIMEOUT,this.onUserActive.bind(this),this.onUserInactive.bind(this)),SL.visibility.changed.add(this.onVisibilityChanged.bind(this)),this.hideOverlay(),this.isEnabled()?this.options.autofocusComment&&this.comments.focus():(this.setEnabled(!0),this.users.showInvitePrompt(this.menu.getPrimaryButton()),this.users.inviteSent.addOnce(this.expand.bind(this))),this.handover&&this.handover.refresh(),this.isInEditor()&&this.currentUserIsEditing()?this.reloadCurrentUser().then(function(){this.currentUserIsEditing()?this.finishLoading():this.redirectToReview()}.bind(this),function(){this.finishLoading()}.bind(this)):this.isInEditor()&&!this.currentUserIsEditing()?this.redirectToReview():this.finishLoading())},finishLoading:function(){this.domElement.removeClass("loading"),this.loaded.dispatch()},reload:function(){this.isConnected()&&(this.showLoadingOverlay("Reloading..."),this.usersCollection.load().then(function(){this.redirectToReviewUnlessEditor()===!1&&(this.users.renderUsers(),SL.helpers.StreamEditor.singleton().emit("broadcast-all-user-states"),this.comments&&this.comments.reload(),this.handover&&this.handover.refresh(),this.hideOverlay())}.bind(this),function(){this.showErrorOverlay("Failed to load collaborators",this.reload.bind(this))}.bind(this)))},reloadCurrentUser:function(){return new Promise(function(t,e){$.ajax({type:"GET",url:SL.endpoints.DECKUSER_READ(SL.current_deck.get("id"),SL.current_user.get("id")),context:this}).done(function(e){var i=this.usersCollection.getByProperties({user_id:e.user_id});i&&i.setAll(e),t()}).fail(e)}.bind(this))},renderContent:function(){this.users=new SL.components.collab.Users(this,{users:this.usersCollection}),this.users.appendTo(this.menu.innerElement),this.comments=new SL.components.collab.Comments(this,{users:this.usersCollection}),this.comments.appendTo(this.bodyElement),this.notifications=new SL.components.collab.Notifications(this,{users:this.usersCollection}),this.notifications.appendTo(this.domElement),this.isInEditor()||(this.handover=new SL.components.collab.Handover(this,{users:this.usersCollection}),this.handover.appendTo(this.options.container))},expand:function(){this.flags.expanded=!0,this.domElement.addClass("expanded"),SL.keyboard.keydown(this.onKeyDown),this.expanded.dispatch()},collapse:function(){this.options.fixed||(this.commentsWhileCollapsed.length=0,this.flags.expanded=!1,this.domElement.removeClass("expanded"),SL.keyboard.release(this.onKeyDown),this.collapsed.dispatch())},toggle:function(){this.isExpanded()?this.collapse():this.expand()},isExpanded:function(){return this.flags.expanded},setEnabled:function(t){this.flags.enabled=t,this.domElement.toggleClass("enabled",t),t?(Reveal.addEventListener("slidechanged",this.onSlideChanged),this.enabled.dispatch()):Reveal.removeEventListener("slidechanged",this.onSlideChanged)},isEnabled:function(){return this.flags.enabled},isConnected:function(){return this.flags.connected},makeDeckCollaborative:function(){this.isEnabled()||$.ajax({type:"POST",url:SL.endpoints.MAKE_DECK_COLLABORATIVE(SL.current_deck.get("id")),context:this}).done(function(){SLConfig.deck.collaborative=!0,this.load()}).fail(function(){this.showErrorOverlay("Failed to enable collaboration",this.makeDeckCollaborative.bind(this))})},showHandoverRequestReceived:function(t){var e="handover-"+t.get("user_id"),i=$(["<div>","<p><strong>"+t.get("username")+"</strong> would like to edit but only one person can edit at a time.</p>",'<button class="button half-width approve-button grey">Let them edit</button>','<button class="button half-width deny-button outline">Dismiss</button>',"</div>"].join(""));i.find(".approve-button").on("vclick",function(){this.becomeEditor(t),this.notifications.hide(e)}.bind(this)),i.find(".deny-button").on("vclick",function(){SL.helpers.StreamEditor.singleton().broadcast({type:"collaboration:handover-denied",user_id:t.get("user_id"),denied_by_user_id:SL.current_user.get("id")}),this.notifications.hide(e)}.bind(this)),this.notifications.show(i,{id:e,optional:!1,sender:t})},showHandoverRequestPending:function(t){var e="handover-pending",i=$(["<div>","<p>You have asked to edit this deck. Waiting to hear back from <strong>"+t.getDisplayName()+"</strong>...</p>",'<button class="button outline cancel-button">Cancel</button>',"</div>"].join(""));i.find(".cancel-button").on("vclick",function(t){t.preventDefault(),SL.helpers.StreamEditor.singleton().broadcast({type:"collaboration:handover-request-canceled",user_id:SL.current_user.get("id")}),this.notifications.hide(e)}.bind(this)),this.notifications.show(i,{id:e,optional:!1,icon:"i-question-mark"})},showLoadingOverlay:function(t){t=t||"Loading...",this.overlayElement.addClass("visible"),this.overlayContent.empty().html('<p class="message">'+t+"</p>"),this.flashOverlay()},showErrorOverlay:function(t,e){this.overlayElement.addClass("visible"),this.overlayContent.empty().html(['<div class="exclamation">!</div>','<p class="message">'+t+"</p>",'<button class="button outline">Try again</button>'].join("")),this.overlayContent.find("button").on("vclick",e),this.flashOverlay()},flashOverlay:function(){clearTimeout(this.flashOverlayTimeout),this.overlayContent.addClass("flash"),this.flashOverlayTimeout=setTimeout(function(){this.overlayContent.removeClass("flash")}.bind(this),1e3)},hideOverlay:function(){this.overlayElement.removeClass("visible")},updatePageTitle:function(){var t="";this.commentsWhileHidden.length&&(t+="("+this.commentsWhileHidden.length+") "),t+=this.isInEditor()?"Edit: ":"Review: ",t+=SL.current_deck.get("title"),document.title=t},currentUserIsEditing:function(){var t=this.getCurrentDeckUser();return!(!t||!t.isEditing())},getCurrentDeckUser:function(){return!this.cachedCurrentDeckUser&&this.usersCollection&&(this.cachedCurrentDeckUser=this.usersCollection.getByUserID(SL.current_user.get("id"))),this.cachedCurrentDeckUser},getCollapsedWidth:function(){return SL.config.EDITOR_FLOATING_ACTION_RADIUS},becomeEditor:function(t){return t=t||this.getCurrentDeckUser(),new Promise(function(e,i){$.ajax({type:"POST",url:SL.endpoints.DECKUSER_BECOME_EDITOR(SL.current_deck.get("id"),t.get("user_id")),context:this}).done(function(){this.usersCollection.setEditing(t.get("user_id")),e(),this.currentUserIsEditing()?this.redirectToEdit():this.redirectToReview()}).fail(function(){SL.notify("Failed to change editors"),i()})}.bind(this))},isInEditor:function(){return this.options.editor},redirectToEdit:function(){if(!this.isInEditor()){SL.helpers.PageLoader.show({message:"Loading"});var t=window.location.hash||"";window.location=SL.routes.DECK_EDIT(SL.current_deck.get("user").username,SL.current_deck.get("slug"))+t}},redirectToReview:function(t){this.isInEditor()&&(SL.helpers.PageLoader.show({message:t||"Loading"}),SL.view.redirect(SL.routes.DECK_REVIEW(SL.current_deck.get("user").username,SL.current_deck.get("slug")),!0))},redirectToReviewUnlessEditor:function(){if(this.isInEditor()&&!this.currentUserIsEditing()){var t=5,e="Someone else started editing.<br>Redirecting in "+t+" seconds...";return SL.helpers.PageLoader.show({message:e}),setTimeout(function(){this.redirectToReview(e)}.bind(this),1e3*t),!0}return!1},onKeyDown:function(t){return!(27===t.keyCode&&!this.options.fixed)||(this.collapse(),!1)},onSlideChanged:function(t){var e=Reveal.getCurrentSlide().getAttribute("data-id");e&&SL.helpers.StreamEditor.singleton().emit("slide-change",e),this.comments&&this.isExpanded()&&this.comments.onSlideChanged(t),this.users&&this.users.layout()},onStreamStatusChanged:function(t){t===SL.helpers.StreamEditor.STATUS_CONNECTED?this.onSocketConnected():t===SL.helpers.StreamEditor.STATUS_DISCONNECTED?this.onSocketDisconnected():t===SL.helpers.StreamEditor.STATUS_RECONNECT_FAILED?this.onSocketReconnectFailed():t===SL.helpers.StreamEditor.STATUS_RECONNECTED&&this.onSocketReconnected()},onStreamMessage:function(t){if(t){var e=t.type.split(":")[0],i=t.type.split(":")[1];"collaboration"===e&&("comment-added"===i?this.onStreamCommentAdded(t):"comment-updated"===i?this.onStreamCommentUpdated(t):"comment-removed"===i?this.onStreamCommentRemoved(t):"user-typing"===i?this.onStreamUserTyping(t):"user-typing-stopped"===i?this.onStreamUserTypingStopped(t):"user-added"===i?this.onStreamUserAdded(t):"user-updated"===i?this.onStreamUserUpdated(t):"user-removed"===i?this.onStreamUserRemoved(t):"presence-changed"===i?this.onStreamPresenceChanged(t):"editor-changed"===i?this.onStreamEditorChanged(t):"handover-requested"===i?this.onStreamHandoverRequested(t):"handover-request-canceled"===i?this.onStreamHandoverRequestCanceled(t):"handover-denied"===i?this.onStreamHandoverDenied(t):"deck-content-changed"===i?this.onStreamDeckContentChanged(t):"deck-settings-changed"===i&&this.onStreamDeckSettingsChanged(t)),this.redirectToReviewUnlessEditor()}},onStreamCommentAdded:function(t){this.comments.addCommentFromStream(t.comment)&&(this.isExpanded()||(this.commentsWhileCollapsed.push(t.comment.id),this.menu.setUnreadComments(this.commentsWhileCollapsed.length)),SL.visibility.isHidden()&&(this.commentsWhileHidden.push(t.comment.id),this.updatePageTitle()))},onStreamCommentUpdated:function(t){this.comments.updateCommentFromStream(t.comment)},onStreamCommentRemoved:function(t){this.comments.removeCommentFromStream(t.comment.id);var e=this.commentsWhileCollapsed.indexOf(t.comment.id);e!==-1&&(this.commentsWhileCollapsed.splice(e,1),this.menu.setUnreadComments(this.commentsWhileCollapsed.length))},onStreamUserTyping:function(t){var e=this.usersCollection.getByProperties({user_id:t.user_id});e&&(e.set("typing",!0),this.comments.refreshTypingIndicators(),clearTimeout(e.typingTimeout),e.typingTimeout=setTimeout(function(){e.set("typing",!1),this.comments.refreshTypingIndicators()}.bind(this),SL.config.COLLABORATION_RESET_WRITING_TIMEOUT))},onStreamUserTypingStopped:function(t){var e=this.usersCollection.getByProperties({user_id:t.user_id});e&&(e.set("typing",!1),this.comments.refreshTypingIndicators(),clearTimeout(e.typingTimeout))},onStreamUserAdded:function(t){this.users.addUserFromStream(t.user)},onStreamUserUpdated:function(t){var e=this.usersCollection.getByProperties({user_id:t.user.user_id});if(e){var i=e.toJSON();e.setAll(t.user),i.active||e.get("active")!==!0||this.users.renderUser(e),e.get("user_id")===SL.current_user.get("id")&&(i.role!==e.get("role")&&this.reload(),this.handover&&this.handover.refresh())}},onStreamUserRemoved:function(t){if(t.user.user_id)if(t.user.user_id===SL.current_user.get("id")){var e=5,i="You were removed from this deck.<br>Redirecting in "+e+" seconds...";SL.helpers.PageLoader.show({message:i}),setTimeout(function(){window.location=SL.routes.USER(SL.current_user.get("username"))}.bind(this),1e3*e)}else this.users.removeUserFromStream(t.user.user_id)},onStreamPresenceChanged:function(t){var e=this.usersCollection.getByProperties({user_id:t.user_id});e&&(t.status&&e.set("status",t.status),t.slide_id&&e.set("slide_id",t.slide_id),this.users.refreshPresence(e),e.isOnline()===!1&&(e.get("typing")&&(e.set("typing",!1),this.comments.refreshTypingIndicators()),this.notifications.hide("handover-"+t.user_id),e.isEditing()&&this.notifications.hide("handover-pending")&&this.becomeEditor()),this.handover&&this.handover.refresh())},onStreamEditorChanged:function(t){t.user.user_id&&(this.usersCollection.setEditing(t.user.user_id),this.currentUserIsEditing()?this.redirectToEdit():this.redirectToReview())},onStreamHandoverRequested:function(t){if(this.currentUserIsEditing()){var e=this.usersCollection.getByProperties({user_id:t.user_id});e&&this.showHandoverRequestReceived(e)}},onStreamHandoverRequestCanceled:function(t){this.notifications.hide("handover-"+t.user_id)},onStreamHandoverDenied:function(t){if(SL.current_user.get("id")===t.user_id){var e=this.usersCollection.getByProperties({user_id:t.denied_by_user_id});e&&(this.notifications.hide("handover-pending"),this.notifications.show("<strong>"+e.getDisplayName()+"</strong> turned down your request to edit. Try again later.",{sender:e}))}},onStreamDeckContentChanged:function(){this.isInEditor()||(this.reloadDeckContentXHR&&this.reloadDeckContentXHR.abort(),this.reloadDeckContentXHR=$.ajax({url:SL.endpoints.GET_DECK_DATA(SL.current_deck.get("id")),type:"GET",context:this}).done(function(t){var e=t.deck.data;this.isInEditor()?SL.editor.controllers.Markup.replaceHTML(e):SL.util.deck.replaceHTML(e),this.handover.refreshSlideNumbers(),this.comments.refreshSlideNumbers()}.bind(this)).always(function(){this.reloadDeckContentXHR=null}.bind(this)))},onStreamDeckSettingsChanged:function(){this.isInEditor()||(this.reloadDeckSettingsXHR&&this.reloadDeckSettingsXHR.abort(),this.reloadDeckSettingsXHR=$.ajax({url:SL.endpoints.GET_DECK(SL.current_deck.get("id")),type:"GET",context:this}).done(function(t){var e=JSON.parse(JSON.stringify(SLConfig.deck));for(var i in t)"object"==typeof t[i]&&delete t[i];$.extend(SLConfig.deck,t);var n=SL.models.Theme.fromDeck(SLConfig.deck);SL.helpers.ThemeController.paint(n,{center:!1}),Reveal.configure({rtl:SLConfig.deck.rtl,loop:SLConfig.deck.should_loop,slideNumber:SLConfig.deck.slide_number}),SLConfig.deck.theme_id!==e.theme_id&&console.warn("Theme changed!"),SLConfig.deck.slug!==e.slug&&window.history&&"function"==typeof window.history.replaceState&&window.history.replaceState(null,SLConfig.deck.title,SL.routes.DECK_REVIEW(SLConfig.deck.user.username,SLConfig.deck.slug)+window.location.hash),SLConfig.deck.title!==e.title&&this.updatePageTitle()}.bind(this)).always(function(){this.reloadDeckSettingsXHR=null}.bind(this)))},onUserActive:function(){SL.helpers.StreamEditor.singleton().emit("active"),this.notifications.hide("editor-is-idle"),this.notifications.release(),$.post(SL.endpoints.DECKUSER_UPDATE_LAST_SEEN_AT(SL.current_deck.get("id")))},onUserInactive:function(){SL.helpers.StreamEditor.singleton().emit("idle"),this.currentUserIsEditing()&&this.usersCollection.hasMoreThanOnePresentEditor()&&(this.notifications.show("You're idle. While away, collaborators are allowed to take over editing.",{id:"editor-is-idle",optional:!1,icon:"i-clock"}),this.notifications.hold())},onVisibilityChanged:function(){SL.visibility.isVisible()&&(this.commentsWhileHidden.length=0,this.updatePageTitle())},onSocketConnectionFailed:function(){this.connectionError||(this.connectionError=new SL.components.RetryNotification('<strong>Sorry, we\u2019re having trouble connecting.</strong><br>If the problem persists, contact us <a href="http://help.slides.com" target="_blank">here</a>.',{type:"negative"}),this.connectionError.startCountdown(0),this.connectionError.destroyed.add(function(){this.connectionError=null}.bind(this)),this.connectionError.retryClicked.add(function(){this.connectionError.startCountdown(0),SL.helpers.StreamEditor.singleton().connect().then(SL.util.noop,SL.util.noop)}.bind(this)))},onSocketConnected:function(){clearTimeout(this.disconnectTimeout),this.connectionError&&this.connectionError.destroy(),this.connectionError&&this.connectionError.hide(),this.domElement.removeClass("disconnected"),this.isConnected()?this.reload():this.afterConnect()},onSocketDisconnected:function(){clearTimeout(this.disconnectTimeout),this.disconnectTimeout=setTimeout(function(){this.domElement.addClass("disconnected"),this.comments.blur(),this.users.dismissPrompts(),this.connectionError||(this.connectionError=new SL.components.RetryNotification("Lost connection to server",{type:"negative"}),this.connectionError.startCountdown(0),this.connectionError.destroyed.add(function(){this.connectionError=null}.bind(this)),this.connectionError.retryClicked.add(function(){this.connectionError.startCountdown(0),SL.helpers.StreamEditor.singleton().connect().then(SL.util.noop,SL.util.noop)}.bind(this)))}.bind(this),6e3)},onSocketReconnecting:function(t){this.connectionError&&this.connectionError.startCountdown(t)},onSocketReconnectFailed:function(){this.connectionError&&this.connectionError.disableCountdown()},onSocketReconnected:function(){clearTimeout(this.disconnectTimeout)},destroy:function(){this.menu&&this.menu.destroy(),this.users&&this.users.destroy(),this.comments&&this.comments.destroy(),this.handover&&this.handover.destroy(),this.options=null,this.domElement.remove()}}),SL("components.collab").CommentThread=Class.extend({init:function(t,e){this.id=t,this.options=e,this.comments=new SL.collections.collab.Comments,this.strings={loadMoreComments:"Load older comments",loadingMoreComments:"Loading..."},this.render(),this.bind()},render:function(){this.domElement=$('<div class="sl-collab-comment-thread empty"></div>'),this.domElement.attr("data-thread-id",this.id),this.domElement.data("thread",this),this.loadMoreButton=$('<button class="load-more-button">'+this.strings.loadMoreComments+"</button>"),this.loadMoreButton.on("vclick",this.onLoadMoreClicked.bind(this)),this.loadMoreButton.appendTo(this.domElement)},renderComment:function(t,e){if(e=e||{},!t.rendered){t.rendered=!0;var i=this.options.users.getByUserID(t.get("user_id"));"undefined"==typeof i&&(i=new SL.models.collab.DeckUser({username:"unknown"}));var n,s=moment(t.get("created_at")),o=s.format("MMM Do")+" at "+s.format("h:mm:ss A");n=s.isBefore(moment().subtract(1,"d"))?s.format("MMM Do"):s.format("h:mm A");var a=i?i.get("first_name"):"N/A";a=(a||"").toLowerCase();var r=$(['<div class="sl-collab-comment">','<div class="comment-sidebar">','<div class="avatar" style="background-image: url(\''+i.get("thumbnail_url")+"')\" />","</div>",'<div class="comment-body">','<span class="author">'+a+"</span>",'<div class="meta">','<span class="meta-time" data-tooltip="'+o+'">'+n+"</span>","</div>",'<p class="message"></p>',"</div>","</div>"].join(""));r.data("model",t),this.refreshComment(r),this.refreshSlideNumber(r),SL.util.device.IS_PHONE||SL.util.device.IS_TABLET||this.renderCommentOptions(r,t),t.stateChanged.add(this.onCommentStateChanged.bind(this,r)),e.prepend?this.domElement.prepend(r):this.domElement.append(r),this.checkOverflow()}},renderCommentOptions:function(t,e){var i=this.getCommentPrivileges(e);if(i.canDelete||i.canEdit){var n=$('<button class="button options-button icon disable-when-disconnected"></button>').appendTo(t.find(".comment-sidebar"));i.canDelete&&i.canEdit?(n.addClass("i-cog"),n.on("click",this.onCommentOptionsClicked.bind(this,t))):i.canDelete?(n.addClass("i-trash"),n.on("click",this.onDeleteComment.bind(this,t))):i.canEdit&&(n.addClass("i-i-pen-alt2"),n.on("click",this.onEditComment.bind(this,t)))}},refreshComment:function(t){if(t){var e=t.data("model");e&&(t.find(".message").text(e.get("message")),t.attr("data-id",e.get("id")),t.attr("data-state",e.getState()))}},refreshCommentByID:function(t){this.refreshComment(this.getCommentByID(t))},refreshSlideNumbers:function(){this.options.slideNumbers&&this.domElement.find(".sl-collab-comment").each(function(t,e){this.refreshSlideNumber($(e))}.bind(this))},refreshSlideNumber:function(t){if(this.options.slideNumbers){var e=SL.util.deck.getSlideNumber(t.data("model").get("slide_hash"));if(e){var i="slide "+e,n=t.find(".meta-slide-number");n.length?n.text(i):t.find(".meta").prepend('<button class="meta-slide-number" data-tooltip="Click to view slide">'+i+"</button>")}else t.find(".meta-slide-number").remove()}},appendTo:function(t){this.domElement.appendTo(t)},bind:function(){this.comments.loadStarted.add(this.onLoadStarted.bind(this)),this.comments.loadCompleted.add(this.onLoadCompleted.bind(this)),this.comments.loadFailed.add(this.onLoadFailed.bind(this)),this.comments.changed.add(this.onCommentsChanged.bind(this)),this.viewSlideCommentsClicked=new signals.Signal,this.layout=this.layout.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.domElement.delegate(".meta-slide-number","vclick",this.onSlideNumberClicked.bind(this)),SL.util.dom.preventTouchOverflowScrolling(this.domElement)},show:function(t){t=t||{},this.getID()===SL.components.collab.Comments.DECK_THREAD?this.comments.isLoaded()||this.comments.isLoading()?(this.refresh(),this.scrollToLatestComment()):this.load():this.load(t.slide_hash||Reveal.getCurrentSlide().getAttribute("data-id")),$(window).on("resize",this.onWindowResize)},hide:function(){$(window).off("resize",this.onWindowResize)},load:function(t){var e=SL.endpoints.COMMENTS_LIST(SL.current_deck.get("id"),t);this.slideHash=t,this.domElement.find(".sl-collab-comment").remove(),this.comments.unload(),this.domElement.addClass("empty"),this.comments.load(e).then(SL.util.noop,SL.util.noop)},reload:function(){this.getID()===SL.components.collab.Comments.DECK_THREAD?this.load():this.load(this.slideHash||Reveal.getCurrentSlide().getAttribute("data-id"))},refresh:function(){this.checkIfEmpty(),this.checkOverflow(),this.checkPagination()},layout:function(){this.checkOverflow()},checkIfEmpty:function(){if(this.comments.isLoaded())if(this.comments.isEmpty()){var t=this.getID()===SL.components.collab.Comments.SLIDE_THREAD?"No comments on this slide":"Nothing here yet.<br>Be the first to comment.";this.getPlaceholder().html('<div class="icon i-comment-stroke"></div><p>'+t+"</p>")}else this.hidePlaceholder(),this.domElement.removeClass("empty")},checkPagination:function(){this.loadMoreButton.toggleClass("visible",!this.comments.isLoading()&&this.comments.isLoaded()&&this.comments.hasNextPage())},checkOverflow:function(){this.domElement.toggleClass("overflowing",this.domElement.prop("scrollHeight")>this.domElement.prop("offsetHeight"))},hidePlaceholder:function(){this.placeholder&&(this.placeholder.remove(),this.placeholder=null)},getCommentPrivileges:function(t){var e={canEdit:!1,canDelete:!1},i=this.options.users.getByUserID(SL.current_user.get("id")),n=this.options.users.getByUserID(t.get("user_id"));if(n&&i){var s=i.get("user_id")===n.get("user_id"),o=i.get("role")===SL.models.collab.DeckUser.ROLE_ADMIN||i.get("role")===SL.models.collab.DeckUser.ROLE_OWNER;
s?(e.canEdit=!0,e.canDelete=!0):o&&(e.canDelete=!0)}return e},scrollToLatestComment:function(){this.domElement.scrollTop(this.domElement.prop("scrollHeight"))},scrollToLatestCommentUnlessScrolled:function(){return this.getScrollOffset()<600&&(this.scrollToLatestComment(),!0)},commentExists:function(t){return!!this.getComments().getByID(t.id)||SL.current_user.get("id")===t.user_id&&this.getTemporaryComments().some(function(e){return e.get("user_id")===t.user_id&&e.get("message")===t.message})},getScrollOffset:function(){var t=this.domElement.get(0);return t.scrollHeight-t.offsetHeight-t.scrollTop},getPlaceholder:function(){return this.placeholder||(this.placeholder=$('<div class="placeholder">'),this.placeholder.appendTo(this.domElement)),this.placeholder},getComments:function(){return this.comments},getTemporaryComments:function(){return this.comments.filter(function(t){return!t.has("id")})},getCommentByID:function(t){return this.domElement.find('.sl-collab-comment[data-id="'+t+'"]')},getSlideHash:function(){return this.slideHash},getID:function(){return this.id},onLoadStarted:function(){this.getPlaceholder().html('<div class="spinner centered" data-spinner-color="#999"></div>'),SL.util.html.generateSpinners()},onLoadCompleted:function(){this.comments.forEach(this.renderComment.bind(this)),this.refresh(),this.scrollToLatestComment()},onLoadFailed:function(){this.getPlaceholder().html('<p class="error">Failed to load comments.</p>')},onWindowResize:function(){this.scrollToLatestComment(),this.layout()},onCommentsChanged:function(t,e){t&&t.length&&t.forEach(this.renderComment.bind(this)),e&&e.length&&e.forEach(function(t){this.getCommentByID(t.get("id")).remove()}.bind(this)),this.refresh()},onCommentStateChanged:function(t,e){var i=e.getState();t.attr("data-id",e.get("id")),t.attr("data-state",i),i===SL.models.collab.Comment.STATE_FAILED?0===t.find(".retry").length&&(t.append(['<div class="retry">','<span class="retry-info">Failed to send</span>','<button class="button outline retry-button">Retry</button>',"</div>"].join("")),t.find(".retry-button").on("click",function(){this.comments.retryCreate(e)}.bind(this)),this.scrollToLatestCommentUnlessScrolled()):t.find(".retry").remove()},onCommentOptionsClicked:function(t){var e=new SL.components.Menu({anchor:t.find(".options-button"),anchorSpacing:15,alignment:"l",destroyOnHide:!0,options:[{label:"Edit",icon:"pen-alt2",callback:this.onEditComment.bind(this,t)},{label:"Delete",icon:"trash",callback:this.onDeleteComment.bind(this,t)}]});e.show()},onEditComment:function(t){var e=t.data("model"),i=SL.prompt({anchor:t.find(".options-button"),alignment:"l",title:"Edit comment",type:"input",confirmLabel:"Save"+SL.util.getKeyboardShortcutName("Enter",{meta:!0,casesensitive:!0,span:!0}),data:{value:e.get("message"),placeholder:"Comment...",multiline:!0}});i.confirmed.add(function(i){"string"==typeof i&&i.trim().length>0&&(e.set("message",i),e.save(["message"]).done(this.refreshComment.bind(this,t)))}.bind(this)),SL.analytics.trackCollaboration("Edit comment")},onDeleteComment:function(t){var e=t.data("model");SL.prompt({anchor:t.find(".options-button"),alignment:"l",title:"Are you sure you want to delete this comment?",type:"select",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Delete</h3>",selected:!0,className:"negative",callback:function(){this.comments.remove(e),e.destroy()}.bind(this)}]}),SL.analytics.trackCollaboration("Delete comment")},onLoadMoreClicked:function(){this.loadMoreButton.prop("disabled",!0).text(this.strings.loadingMoreComments),this.comments.loadNextPage().then(function(t){var e=this.domElement.scrollTop(),i=this.domElement.prop("scrollHeight");t.reverse().forEach(function(t){this.renderComment(t,{prepend:!0})}.bind(this));var n=this.domElement.prop("scrollHeight");this.domElement.scrollTop(n-i+e),this.checkPagination()}.bind(this))["catch"](function(){SL.notify("Failed to load comments","negative")}.bind(this)).then(function(){this.loadMoreButton.prop("disabled",!1).text(this.strings.loadMoreComments),this.loadMoreButton.prependTo(this.domElement)}.bind(this))},onSlideNumberClicked:function(t){var e=$(t.target).closest(".sl-collab-comment");e.length&&e.data("model")&&this.viewSlideCommentsClicked.dispatch(e.data("model").get("slide_hash"))},destroy:function(){this.viewSlideCommentsClicked.dispose(),this.domElement.remove()}}),SL("components.collab").Comments=Class.extend({init:function(t,e){this.controller=t,this.options=e,this.render(),this.bind(),this.getCurrentThread()||this.showThread(SL.components.collab.Comments.DECK_THREAD),this.refreshCommentInput(),this.refreshCurrentSlide(),this.getCurrentThread().scrollToLatestComment(),this.layout()},render:function(){this.domElement=$('<div class="sl-collab-page sl-collab-comments"></div>'),this.renderHeader(),this.bodyElement=$('<div class="sl-collab-page-body sl-collab-comments-body">'),this.bodyElement.appendTo(this.domElement),this.footerElement=$('<footer class="sl-collab-page-footer">'),this.footerElement.appendTo(this.domElement),this.renderThreads(),this.renderCommentForm()},renderHeader:function(){this.headerElement=$('<header class="sl-collab-page-header sl-collab-comments-header"></header>'),this.headerElement.appendTo(this.domElement),this.headerElement.html(['<div class="header-tab selected" data-thread-id="deck">All comments</div>','<div class="header-tab header-tab-slide" data-thread-id="slide">Current slide</div>'].join("")),this.headerElement.find(".header-tab").on("vclick",function(t){this.showThread($(t.currentTarget).attr("data-thread-id")),SL.util.device.IS_PHONE||SL.util.device.IS_TABLET||this.commentInput.focus()}.bind(this))},renderThreads:function(){this.threads={},this.threads.deck=new SL.components.collab.CommentThread(SL.components.collab.Comments.DECK_THREAD,{users:this.options.users,slideNumbers:!0}),this.threads.deck.viewSlideCommentsClicked.add(this.onViewSlideCommentsClicked.bind(this)),this.threads.deck.appendTo(this.bodyElement),this.threads.slide=new SL.components.collab.CommentThread(SL.components.collab.Comments.SLIDE_THREAD,{users:this.options.users}),this.threads.slide.appendTo(this.bodyElement)},renderCommentForm:function(){this.commentForm=$('<form action="#" class="sl-collab-comment-form sl-form disable-when-disconnected" novalidate>'),this.commentForm.on("submit",this.onCommentSubmit.bind(this)),SL.util.device.IS_PHONE||SL.util.device.IS_TABLET?this.commentInput=$('<input type="text" autocapitalize="sentences" class="comment-input" placeholder="Add a comment..." required maxlength="'+SL.config.COLLABORATION_COMMENT_MAXLENGTH+'" />'):this.commentInput=$('<textarea class="comment-input" placeholder="Add a comment..." required maxlength="'+SL.config.COLLABORATION_COMMENT_MAXLENGTH+'"></textarea>'),this.commentInput.on("keydown",this.onCommentKeyDown.bind(this)),this.commentInput.on("input",this.onCommentChanged.bind(this)),this.commentInput.on("focus",this.onCommentInputFocus.bind(this)),this.commentInput.appendTo(this.commentForm),this.commentInputFooter=$('<div class="comment-footer"></div>'),this.commentInputFooter.appendTo(this.commentForm),this.commentTyping=$('<div class="comment-typing"></div>'),this.commentTyping.appendTo(this.commentInputFooter),this.commentSubmitButton=$('<input class="comment-submit" type="submit" value="Send" />'),this.commentSubmitButton.on("vclick",this.submitComment.bind(this)),this.commentSubmitButton.appendTo(this.commentInputFooter),this.commentInputFooter.append('<div class="clear"></div>'),this.commentForm.appendTo(this.footerElement)},bind:function(){this.layout=this.layout.bind(this),this.startTyping=this.startTyping.bind(this),this.stopTyping=this.stopTyping.bind(this),$(window).on("resize",this.layout),this.controller.expanded.add(this.onCollaborationExpanded.bind(this)),this.controller.isInEditor()&&SL.editor.controllers.Markup.slidesChanged.add(this.refreshSlideNumbers.bind(this))},appendTo:function(t){this.domElement.appendTo(t)},layout:function(){this.checkOverflow()},reload:function(){this.threads.deck.reload();var t=this.getCurrentThread();t&&t.getID()===SL.components.collab.Comments.SLIDE_THREAD&&t.reload()},focus:function(){this.commentInput.focus()},blur:function(){this.commentInput.blur()},checkOverflow:function(){this.domElement.toggleClass("overflowing",this.bodyElement.prop("scrollHeight")>this.bodyElement.prop("offsetHeight"))},showCommentNotification:function(t){var e=this.options.users.getByUserID(t.get("user_id"));if(e&&e.get("user_id")!==SL.current_user.get("id")){var i="<strong>"+e.getDisplayName()+"</strong>",n=SL.util.deck.getSlideNumber(t.get("slide_hash"));n&&(i+='<span class="slide-number">slide '+n+"</span>"),i+="<br>"+t.get("message"),this.controller.notifications.show(i,{sender:e,callback:function(){this.showSlideComments(t.get("slide_hash")),this.commentInput.focus()}.bind(this)})}},showSlideComments:function(t){this.controller.isExpanded()===!1&&this.controller.expand();var e=$('.reveal .slides section[data-id="'+t+'"]').get(0);SL.util.deck.navigateToSlide(e);var i=this.getCurrentThread();i&&i.getID()!==SL.components.collab.Comments.SLIDE_THREAD&&(this.showThread(SL.components.collab.Comments.SLIDE_THREAD,{slide_hash:t}),SL.util.device.IS_PHONE||SL.util.device.IS_TABLET||this.commentInput.focus())},showThread:function(t,e){var i=this.getCurrentThread(),n=this.bodyElement.find('[data-thread-id="'+t+'"]'),s=n.data("thread");s&&(i&&i!==s&&i.hide(),this.bodyElement.find(".sl-collab-comment-thread").removeClass("visible"),n.addClass("visible"),this.headerElement.find(".header-tab").removeClass("selected"),this.headerElement.find('.header-tab[data-thread-id="'+t+'"]').addClass("selected"),s.show(e))},getCurrentThread:function(){return this.domElement.find(".sl-collab-comment-thread.visible").data("thread")},addCommentFromStream:function(t){if(t.id||console.warn("Can not insert comment without ID"),!this.threads.deck.commentExists(t)){var e=this.controller.isExpanded(),i=this.threads.deck.getComments().createModel(t),n=!1;return this.getCurrentThread().getID()===SL.components.collab.Comments.DECK_THREAD?n=this.threads.deck.scrollToLatestCommentUnlessScrolled():this.getCurrentThread().getID()===SL.components.collab.Comments.SLIDE_THREAD&&t.slide_hash&&t.slide_hash===this.getCurrentThread().getSlideHash()&&!this.getCurrentThread().commentExists(t)&&(this.threads.slide.getComments().createModel(t),n=this.threads.slide.scrollToLatestCommentUnlessScrolled()),e&&n||this.showCommentNotification(i),!0}return!1},updateCommentFromStream:function(t){t.id||console.warn("Can not update comment without ID");var e=this.threads.deck.getComments().getByID(t.id);if(e){for(var i in t)e.set(i,t[i]);this.threads.deck.refreshCommentByID(e.get("id")),this.getCurrentThread().getID()===SL.components.collab.Comments.SLIDE_THREAD&&this.threads.slide.refreshCommentByID(e.get("id"))}},removeCommentFromStream:function(t){return this.threads.deck.getComments().removeByProperties({id:t})},refreshCommentInput:function(){this.commentInput.attr("rows",2);var t=Math.ceil(parseFloat(this.commentInput.css("line-height"))),e=this.commentInput.prop("scrollHeight"),i=this.commentInput.prop("clientHeight"),n=10;e>i&&this.commentInput.attr("rows",Math.min(Math.floor(e/t),n)),this.getCurrentThread().scrollToLatestCommentUnlessScrolled(t*n)},refreshTyping:function(){var t=this.commentInput.val();t?this.startTyping():this.stopTyping()},startTyping:function(){var t=Date.now();this.typing=!0,(!this.lastTypingEvent||t-this.lastTypingEvent>SL.config.COLLABORATION_SEND_WRITING_INTERVAL)&&(this.lastTypingEvent=t,SL.helpers.StreamEditor.singleton().broadcast({type:"collaboration:user-typing",user_id:SL.current_user.get("id")}))},stopTyping:function(){this.typing&&(this.typing=!1,this.lastTypingEvent=null,SL.helpers.StreamEditor.singleton().broadcast({type:"collaboration:user-typing-stopped",user_id:SL.current_user.get("id")}))},refreshTypingIndicators:function(){var t=this.options.users.filter(function(t){return t.get("typing")===!0});0===t.length?this.commentTyping.empty().removeAttr("data-tooltip"):1===t.length?this.commentTyping.html("<strong>"+t[0].getDisplayName()+"</strong> is typing").removeAttr("data-tooltip"):t.length>1&&(this.commentTyping.html("<strong>"+t.length+" people</strong> are typing"),this.commentTyping.attr("data-tooltip",t.map(function(t){return t.getDisplayName()}).join("<br>")))},refreshCurrentSlide:function(){var t=this.getCurrentThread();t&&t.getID()===SL.components.collab.Comments.SLIDE_THREAD&&this.showThread(SL.components.collab.Comments.SLIDE_THREAD,{slide_hash:Reveal.getCurrentSlide().getAttribute("data-id")});var e=SL.util.deck.getSlideNumber(Reveal.getCurrentSlide());e&&this.headerElement.find(".header-tab-slide").text("Slide "+e)},refreshSlideNumbers:function(){this.threads.deck.refreshSlideNumbers()},submitComment:function(){var t=this.commentInput.val();t=t.trim(),t=t.replace(/(\n|\r){3,}/gim,"\n\n"),t.length&&(this.getCurrentThread().getComments().create({comment:{slide_hash:Reveal.getCurrentSlide().getAttribute("data-id"),message:t,user_id:SL.current_user.get("id"),created_at:Date.now()}}),this.commentInput.val(""),this.stopTyping(),this.refreshCommentInput(),this.getCurrentThread().scrollToLatestComment())},onCommentSubmit:function(t){this.submitComment(),t.preventDefault()},onCommentKeyDown:function(t){13!==t.keyCode||t.shiftKey||(this.submitComment(),t.preventDefault(),t.stopPropagation())},onCommentChanged:function(){this.refreshCommentInput(),this.refreshTyping()},onCommentInputFocus:function(){this.refreshTyping()},onViewSlideCommentsClicked:function(t){this.showSlideComments(t)},onSlideChanged:function(){this.refreshCurrentSlide()},onCollaborationExpanded:function(){this.refreshCurrentSlide(),setTimeout(this.focus.bind(this),100)},destroy:function(){this.threads.deck.destroy(),this.threads.slide.destroy(),this.options=null,this.domElement.remove()}}),SL.components.collab.Comments.DECK_THREAD="deck",SL.components.collab.Comments.SLIDE_THREAD="slide",SL("components.collab").Handover=Class.extend({init:function(t,e){this.controller=t,this.options=e,this.render(),this.bind()},render:function(){this.domElement=$('<div class="sl-collab-handover">'),this.editButtonWrapper=$('<div class="edit-button-wrapper">').appendTo(this.domElement),this.editButton=$('<div class="edit-button">'),this.editButton.append('<span class="label">Edit </span><span class="icon i-pen-alt2"></span>'),this.editButton.appendTo(this.editButtonWrapper),this.user=$('<div class="user"></div>'),this.userAvatar=$('<div class="user-avatar"></div>').appendTo(this.user),this.userDescription=$('<div class="user-description"></div>').appendTo(this.user),this.userStatus=$('<div class="user-status"></div>').appendTo(this.userDescription),this.userSlide=$('<div class="user-slide"></div>').appendTo(this.userDescription)},appendTo:function(t){this.domElement.appendTo(t)},bind:function(){this.editButtonWrapper.on("vclick",this.onEditClicked.bind(this))},refresh:function(){this.controller.getCurrentDeckUser().isEditing()||!this.controller.getCurrentDeckUser().canEdit()?(this.editButtonWrapper.removeClass("visible"),this.editButtonWrapper.removeAttr("data-tooltip"),this.user.remove()):(this.editButtonWrapper.addClass("visible"),this.currentEditor=this.options.users.getByProperties({editing:!0}),this.currentEditor&&this.currentEditor.isOnline()?(this.currentAvatarURL!==this.currentEditor.get("thumbnail_url")&&(this.currentAvatarURL=this.currentEditor.get("thumbnail_url"),this.userAvatar.css("background-image",'url("'+this.currentAvatarURL+'")')),0===this.user.parent().length&&this.user.appendTo(this.editButtonWrapper),this.refreshSlideNumbers(),this.currentEditor.isIdle()?(this.editButtonWrapper.attr("data-tooltip","<strong>"+this.currentEditor.get("username")+"</strong> is editing but has been idle for a while.<br>Click to start editing."),this.userStatus.html('<span class="username">'+this.currentEditor.get("username")+"</span> is idle"),this.user.addClass("idle")):(this.editButtonWrapper.attr("data-tooltip","Ask <strong>"+this.currentEditor.get("username")+"</strong> to make you the active editor"),this.userStatus.html('<span class="username">'+this.currentEditor.get("username")+"</span> is editing"),this.user.removeClass("idle"))):(this.user.remove(),this.editButtonWrapper.removeAttr("data-tooltip")))},refreshSlideNumbers:function(){if(this.currentEditor){var t=SL.util.deck.getSlideNumber(this.currentEditor.get("slide_id"));t?this.userSlide.addClass("visible").html("slide "+t).data("data-slide-id",this.currentEditor.get("slide_id")).attr("data-tooltip","Click to view slide"):this.userSlide.removeClass("visible")}},onEditClicked:function(t){if($(t.target).closest(".user-slide").length){var e=this.userSlide.data("data-slide-id"),i=$('.reveal .slides section[data-id="'+e+'"]').get(0);i&&SL.util.deck.navigateToSlide(i)}else if(!this.controller.getCurrentDeckUser().isEditing()){var n=this.options.users.getByProperties({editing:!0});n&&n.isOnline()&&!n.isIdle()?(SL.helpers.StreamEditor.singleton().broadcast({type:"collaboration:handover-requested",user_id:SL.current_user.get("id")}),this.controller.showHandoverRequestPending(n)):this.controller.becomeEditor()}},destroy:function(){this.domElement.remove()}}),SL("components.collab").Menu=Class.extend({init:function(t,e){this.controller=t,this.options=e,this.render(),this.bind()},render:function(){this.domElement=$('<div class="sl-collab-menu">'),this.innerElement=$('<div class="sl-collab-menu-inner">'),this.innerElement.appendTo(this.domElement),this.renderProfile()},renderProfile:function(){this.enableButton=$('<div class="sl-collab-menu-item sl-collab-menu-enable ladda-button" data-style="zoom-in" data-spinner-color="#fff" data-tooltip="Add a collaborator" data-tooltip-alignment="l">'),this.enableButton.append('<span class="users-icon icon i-users"></span>'),this.enableButton.appendTo(this.innerElement),this.toggleButton=$('<div class="sl-collab-menu-item sl-collab-menu-toggle">'),this.toggleButton.append('<div class="users-icon icon i-users"></div>'),this.toggleButton.append('<div class="close-icon icon i-x"></div>'),this.toggleButton.appendTo(this.innerElement),this.unreadComments=$('<div class="unread-comments" data-tooltip="Unread comments" data-tooltip-alignment="l">'),this.unreadComments.appendTo(this.toggleButton)},appendTo:function(t){this.domElement.appendTo(t)},bind:function(){this.onEnableClicked=this.onEnableClicked.bind(this),this.onToggleClicked=this.onToggleClicked.bind(this),this.enableButton.on("vclick",this.onEnableClicked),this.toggleButton.on("vclick",this.onToggleClicked),this.controller.enabled.add(this.onCollaborationEnabled.bind(this)),this.controller.expanded.add(this.onCollaborationExpanded.bind(this))},setUnreadComments:function(t){0===t?this.clearUnreadComments():this.unreadComments.text(t).addClass("visible")},clearUnreadComments:function(){this.unreadComments.removeClass("visible")},destroy:function(){this.domElement.remove()},getPrimaryButton:function(){return this.toggleButton},onEnableClicked:function(t){this.enableButton.off("vclick",this.onEnableClicked),this.enableLoader=Ladda.create(this.enableButton.get(0)),this.enableLoader.start(),SL.view.isNewDeck()?SL.view.save(function(){this.controller.makeDeckCollaborative()}.bind(this)):this.controller.makeDeckCollaborative(),t.preventDefault()},onToggleClicked:function(t){this.controller.toggle(),t.preventDefault()},onCollaborationEnabled:function(){this.enableLoader&&(this.enableLoader.stop(),this.enableLoader=null)},onCollaborationExpanded:function(){this.clearUnreadComments()}}),SL("components.collab").Notifications=Class.extend({init:function(t,e){this.controller=t,this.options=e,this.render(),this.bind()},render:function(){this.domElement=$('<div class="sl-collab-notifications">')},bind:function(){this.domElement.delegate(".sl-collab-notification.optional","mouseenter",this.onNotificationMouseEnter.bind(this)),this.domElement.delegate(".sl-collab-notification.optional","vclick",this.onNotificationClick.bind(this))},appendTo:function(t){this.domElement.appendTo(t)},show:function(t,e){e=$.extend({optional:!0,duration:5e3},e);var i;e.id&&(i=this.getNotificationByID(e.id)),i&&0!==i.length||(i=this.addNotification(t,e),e.optional&&(this.holding?i.addClass("on-hold"):this.hideAfter(i,e.duration)))},hide:function(t){var e=this.getNotificationByID(t);return!!e.length&&(this.removeNotification(e),!0)},hideAfter:function(t,e){setTimeout(function(){t.addClass("hide"),setTimeout(this.removeNotification.bind(this,t),500)}.bind(this),e)},hold:function(){this.holding=!0},release:function(){this.holding=!1;var t=this.domElement.find(".sl-collab-notification.on-hold").get().reverse();t.forEach(function(t,e){this.hideAfter($(t),5e3+1e3*e)},this)},addNotification:function(t,e){var i=$('<div class="sl-collab-notification" />').data("options",e).toggleClass("optional",e.optional).prependTo(this.domElement),t=$('<div class="message" />').append(t).appendTo(i);return i.toggleClass("multiline",t.height()>24),e.sender?$('<div class="status-picture" />').css("background-image",'url("'+e.sender.get("thumbnail_url")+'")').prependTo(i):$('<div class="status-icon icon" />').addClass(e.icon||"i-info").prependTo(i),e.id&&i.attr("data-id",e.id),this.layout(),setTimeout(function(){i.addClass("show")},1),i},removeNotification:function(t){t.removeData(),t.remove(),this.layout()},getNotificationByID:function(t){return this.domElement.find(".sl-collab-notification[data-id="+t+"]")},layout:function(){var t=0;this.domElement.find(".sl-collab-notification").each(function(e,i){i.style.top=t+"px",t+=i.offsetHeight+10})},destroy:function(){this.domElement.remove()},onNotificationMouseEnter:function(t){var e=$(t.currentTarget);0===e.find(".dismiss").length&&$('<div class="dismiss"><span class="icon i-x"></span></div>').appendTo(e)},onNotificationClick:function(t){var e=$(t.currentTarget);if(0===$(t.target).closest(e.find(".dismiss")).length){var i=e.data("options").callback;"function"==typeof i&&i.call()}this.removeNotification(e)}}),SL("components.collab").Users=Class.extend({init:function(t,e){this.controller=t,this.options=e,this.inviteSent=new signals.Signal,this.render(),this.bind()},render:function(){this.domElement=$('<div class="sl-collab-users disable-when-disconnected">'),this.userList=$('<div class="sl-collab-users-list">').appendTo(this.domElement),this.slideGroup=$('<div class="sl-collab-users-group">').appendTo(this.userList),this.slideGroup.append('<div class="icon i-eye"></div>'),this.slideGroup.find(".icon").attr({"data-tooltip":"People who are viewing the current slide","data-tooltip-alignment":"l"}),this.inviteButton=$('<div class="sl-collab-menu-item sl-collab-users-invite" data-tooltip="Add a collaborator" data-tooltip-alignment="l"></div>'),this.inviteButton.html('<span class="icon i-plus"></span>'),this.inviteButton.on("vclick",this.onInviteClicked.bind(this)),this.inviteButton.appendTo(this.domElement),this.renderUsers()},renderUsers:function(){this.domElement.toggleClass("admin",this.controller.getCurrentDeckUser().isAdmin()),this.layoutPrevented=!0,this.userList.find(".sl-collab-user").remove(),this.options.users.forEach(this.renderUser.bind(this)),this.layoutPrevented=!1,this.layout()},renderUser:function(t){if(t.get("user_id")!==SL.current_user.get("id")&&t.get("active")!==!1){t._watchingActive||(t._watchingActive=!0,t.watch("active",function(){t.isActive()?this.onUsersChanged([t]):this.onUsersChanged(null,[t])}.bind(this)));var e=this.getUserByID(t.get("user_id"));return 0===e.length&&(e=$("<div/>",{"class":"sl-collab-user","data-user-id":t.get("user_id")}),e.html('<div class="picture" style="background-image: url(\''+t.get("thumbnail_url")+"')\" />"),e.data("model",t),e.on("mouseenter",this.onUserMouseEnter.bind(this)),e.appendTo(this.userList)),this.refreshPresence(t),e}},renderRoleSelector:function(){var t=$(['<select class="sl-select role-selector">','<option value="'+SL.models.collab.DeckUser.ROLE_EDITOR+'">Editor \u2013 Can comment and edit</option>','<option value="'+SL.models.collab.DeckUser.ROLE_VIEWER+'">Viewer \u2013 Can comment</option>',"</select>"].join(""));return SL.current_deck.user.isEnterprise()&&t.prepend('<option value="'+SL.models.collab.DeckUser.ROLE_ADMIN+'">Admin \u2013 Can comment, edit and manage users</option>'),t},renderInviteForm:function(){this.inviteForm||(this.inviteForm=$('<div class="sl-collab-invite-form sl-form">'),this.inviteEmail=$('<input class="invite-email" type="text" placeholder="Email address..." />'),this.inviteEmail.on("input",this.onEmailInput.bind(this)),this.inviteEmail.appendTo(this.inviteForm),this.inviteRole=this.renderRoleSelector(),this.inviteRole.appendTo(this.inviteForm),this.inviteOptions=$('<div class="invite-options">'),this.inviteOptions.appendTo(this.inviteForm),this.inviteFooter=$(['<footer class="footer">','<button class="button l outline cancel-button">Cancel</button>','<button class="button l confirm-button">Send</button>',"</footer>"].join("")),this.inviteFooter.find(".cancel-button").on("vclick",this.onInviteCancelClicked.bind(this)),this.inviteFooter.find(".confirm-button").on("vclick",this.onInviteConfirmClicked.bind(this)),this.inviteFooter.appendTo(this.inviteForm),SL.current_user.isEnterprise()&&(this.inviteEmailAutocomplete=new SL.components.form.Autocomplete(this.inviteEmail,this.searchTeamMembers.bind(this),{className:"light-grey",offsetY:1}),this.inviteEmailAutocomplete.confirmed.add(this.onEmailInput.bind(this)))),this.inviteEmail.val(""),this.inviteOptions.empty(),this.inviteRole.find("[hidden]").prop("hidden",!1),this.inviteRole.find('[value="'+SL.models.collab.DeckUser.ROLE_EDITOR+'"]').prop("selected",!0),this.inviteRole.prop("disabled",!1);var t=SL.current_deck.user;if(SL.current_deck.isVisibilityAll()||!t.isPaid()||t.isEnterprise()){if(t.isEnterprise()&&SL.current_user.isEnterpriseManager()){this.inviteOptionsForTeams=!0,this.inviteOptions.append("<p>Want this person to be able to access internal presentations and create decks of their own?</p>"),this.inviteOptions.addClass("hidden");var e=$(['<div class="unit sl-checkbox outline">','<input id="team-invite-checkbox" class="team-invite-checkbox" type="checkbox" />','<label for="team-invite-checkbox">Add to team</label>',"</div>"].join("")).appendTo(this.inviteOptions);this.inviteToTeamLabel=e.find("label"),this.inviteToTeamInput=e.find("input"),SL.current_team.isManuallyUpgraded()||this.inviteToTeamLabel.html("Add to team for "+SL.current_team.getCostPerUser())}}else{var i=this.options.users.getEditors().length-1,n=SL.current_deck.get("deck_user_editor_limit")||50,s=n-i;i>=n?(this.inviteRole.find('[value="'+SL.models.collab.DeckUser.ROLE_EDITOR+'"]').prop("hidden",!0),this.inviteRole.find('[value="'+SL.models.collab.DeckUser.ROLE_VIEWER+'"]').prop("selected",!0),this.inviteRole.prop("disabled",!0),this.inviteOptions.html("You can't invite any more editors to this deck on your current plan, but you can add any number of viewers. Please <a href=\""+SL.routes.PRICING+'" target="_blank">upgrade</a> to add more editors.')):this.inviteOptions.html('You can invite <span class="semibold">'+s+"</span> more "+SL.util.string.pluralize("editor","s",s>1)+".")}return this.inviteForm},renderEditForm:function(t){this.editForm||(this.editForm=$('<div class="sl-collab-edit-form sl-form">'),this.editRole=this.renderRoleSelector(),this.editRole.appendTo(this.editForm),this.editFooter=$(['<footer class="footer">','<button class="button l negative delete-button" style="float: left;">Remove</button>','<button class="button l outline cancel-button">Cancel</button>','<button class="button l confirm-button">Save</button>',"</footer>"].join("")),this.editFooter.find(".delete-button").on("vclick",this.onEditDeleteClicked.bind(this)),this.editFooter.find(".cancel-button").on("vclick",this.onEditCancelClicked.bind(this)),this.editFooter.find(".confirm-button").on("vclick",this.onEditConfirmClicked.bind(this)),this.editFooter.appendTo(this.editForm)),this.editRole.find('[value="'+t.get("role")+'"]').prop("selected",!0),this.editRole.prop("disabled",!1);var e=SL.current_deck.user;if(!SL.current_deck.isVisibilityAll()&&e.isPaid()&&!e.isEnterprise()){var i=this.options.users.getEditors().length-1,n=SL.current_deck.get("deck_user_editor_limit")||50;i>=n&&t.get("role")===SL.models.collab.DeckUser.ROLE_VIEWER&&this.editRole.prop("disabled",!0)}return this.editForm},bind:function(){this.options.users.changed.add(this.onUsersChanged.bind(this)),this.domElement.delegate(".sl-collab-user","vclick",this.onUserClicked.bind(this)),this.layout=this.layout.bind(this),this.controller.expanded.add(this.layout),this.controller.collapsed.add(this.layout),$(window).on("resize",$.throttle(this.layout,300))},appendTo:function(t){this.domElement.appendTo(t)},refreshPresence:function(t){var e=this.getUserByID(t.get("user_id"));e&&e.length&&(e.removeClass("intro-animation"),e.toggleClass("online",t.isOnline()),e.toggleClass("idle",t.isIdle()),this.layout())},layout:function(){if(this.layoutPrevented)return!1;var t=62;this.domElement.css("max-height",window.innerHeight-t);var e=this.userList.find(".sl-collab-user.online").get(),i=this.userList.find(".sl-collab-user:not(.online)").get(),n=30,s=26,o=16,a=10;if(this.slideGroup.removeClass("visible"),e.length){var r=SL.util.deck.getSlideID(Reveal.getCurrentSlide()),l=0,d=4;e=e.filter(function(t){return $(t).data("model").get("slide_id")!==r||(t.style.transform="translateY("+a+"px)",a+=s,l+=1,!1)}),l>0&&(this.slideGroup.css({top:d,height:a+2*d}).addClass("visible"),a+=o+6),e.length&&(e.forEach(function(t){t.style.transform="translateY("+a+"px)",a+=s}),a+=o)}i.length&&(this.controller.isExpanded()?(i.forEach(function(t){t.style.transform="translateY("+a+"px)",a+=s}),a+=o):i.forEach(function(t){t.style.transform="translateY("+a+"px)"})),this.inviteButton&&(this.inviteButton.get(0).style.transform="translateY("+a+"px)",a+=n+o),this.userList.css("height",a)},addUserFromStream:function(t){t.user_id||console.warn("Can not insert collaborator without ID");var e=this.options.users.getByProperties({user_id:t.user_id});e?(e.setAll(t),e.set("active",!0)):this.options.users.createModel(t)},removeUserFromStream:function(t){var e=this.options.users.getByProperties({user_id:t});e&&e.set("active",!1)},getUserByID:function(t){return this.domElement.find('.sl-collab-user[data-user-id="'+t+'"]')},showInvitePrompt:function(t){this.invitePrompt||(this.invitePrompt=SL.prompt({anchor:t||this.inviteButton,alignment:"l",type:"custom",title:"Add a collaborator",html:this.renderInviteForm(),destroyAfterConfirm:!1,confirmOnEnter:!0}),this.invitePrompt.confirmed.add(function(){this.inviteEmail.blur(),this.confirmInvitePrompt().then(function(){this.inviteSent.dispatch(),this.invitePrompt&&this.invitePrompt.destroy()}.bind(this),function(){})}.bind(this)),this.invitePrompt.destroyed.add(function(){this.inviteForm.detach(),this.invitePrompt=null}.bind(this)),this.inviteEmail.focus())},confirmInvitePrompt:function(){var t=this.inviteEmail.val().trim(),e=this.inviteRole.val(),i=!(!this.inviteToTeamInput||!this.inviteToTeamInput.is(":checked"));return new Promise(function(n,s){if(/^[A-Z0-9._%+\-]+@[A-Z0-9.\-]+\.[A-Z]{2,}$/gi.test(t)){this.invitePrompt.showOverlay("neutral","Inviting "+t,'<div class="spinner" data-spinner-color="#333"></div>'),SL.util.html.generateSpinners();var o={user:{email:t,role:e}};i&&(o.user.add_to_team=!0);var a={url:SL.endpoints.DECKUSER_CREATE(SLConfig.deck.id),createModel:!1},r=this.options.users.getByProperties({email:t});r&&(a.model=r),this.options.users.create(o,a).then(function(){this.invitePrompt.showOverlay("positive","Invite sent!",'<span class="icon i-checkmark"></span>',2e3).then(n)}.bind(this),function(t){var e="Failed to send invite. Please try again.";t&&t.responseJSON&&t.responseJSON.email&&t.responseJSON.email.length>0&&(e="<strong>Failed to send invite.</strong><br>"+t.responseJSON.email[0]),this.invitePrompt.showOverlay("negative",e,'<span class="icon i-x"></span>',3e3).then(s),this.inviteEmail.focus().select()}.bind(this))}else SL.notify("Please enter a valid email","negative"),this.inviteEmail.focus().select(),s()}.bind(this))},showEditPrompt:function(t){if(!this.editPrompt){var e=t.data("model");if(e.get("role")===SL.models.collab.DeckUser.ROLE_OWNER)return;this.editUserElement=t,this.editUserModel=e,this.editPrompt=SL.prompt({anchor:t,alignment:"l",type:"custom",title:e.get("email"),html:this.renderEditForm(e),destroyAfterConfirm:!1,confirmOnEnter:!0}),this.editPrompt.confirmed.add(function(){this.confirmEditPrompt().then(function(){this.editPrompt&&this.editPrompt.destroy()}.bind(this))}.bind(this)),this.editPrompt.destroyed.add(function(){
this.editForm.detach(),this.editPrompt=null}.bind(this))}},confirmEditPrompt:function(){var t=this.editUserModel;return new Promise(function(e,i){var n=this.editRole.val();n&&n!==t.get("role")?(this.editPrompt.showOverlay("neutral","Saving",'<div class="spinner" data-spinner-color="#333"></div>'),SL.util.html.generateSpinners(),t.set("role",n),t.save(["role"]).then(function(){e()}.bind(this),function(){this.editPrompt.showOverlay("negative","Failed to save changes. Please try again.",'<span class="icon i-x"></span>',2e3).then(i)}.bind(this))):e()}.bind(this))},searchTeamMembers:function(t){return this.searchTeamMembersXHR&&this.searchTeamMembersXHR.abort(),this.searchTeamMemberEmailCache||(this.searchTeamMemberEmailCache={}),new Promise(function(e,i){this.searchTeamMembersXHR=$.ajax({type:"POST",url:SL.endpoints.TEAM_MEMBER_SEARCH,context:this,data:{q:t}}).done(function(t){var i=t.results;i=i.filter(function(t){return t.id!==SL.current_user.get("id")}),i.forEach(function(t){this.searchTeamMemberEmailCache[t.email]=!0}.bind(this)),i=i.slice(0,5).map(function(t){return{value:t.email,label:'<div class="label">'+t.name+'</div><div class="value">'+t.email+"</div>"}}),e(i)}).fail(i)}.bind(this))},dismissPrompts:function(){this.editPrompt&&this.editPrompt.destroy(),this.invitePrompt&&this.invitePrompt.destroy()},onUsersChanged:function(t,e){t&&t.forEach(function(t){var e=this.renderUser(t);e&&(setTimeout(function(){e.addClass("intro-animation")},1),this.layout())}.bind(this)),e&&e.forEach(function(t){var e=$('.sl-collab-user[data-user-id="'+t.get("user_id")+'"]');SL.util.anim.collapseListItem(e,function(){e.remove(),this.layout()}.bind(this),300)},this)},onInviteClicked:function(t){t.preventDefault(),this.showInvitePrompt()},onInviteCancelClicked:function(){this.invitePrompt&&this.invitePrompt.cancel()},onInviteConfirmClicked:function(){this.invitePrompt&&this.invitePrompt.confirm()},onEditCancelClicked:function(){this.editPrompt&&this.editPrompt.cancel()},onEditConfirmClicked:function(){this.editPrompt&&this.editPrompt.confirm()},onEditDeleteClicked:function(){this.editPrompt&&this.editPrompt.destroy();var t=this.editUserModel;SL.prompt({anchor:this.editUserElement,title:SL.locale.get("COLLABORATOR_REMOVE_CONFIRM"),alignment:"l",type:"select",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Remove</h3>",selected:!0,className:"negative",callback:function(){t.destroy().then(function(){t.set("active",!1)})}.bind(this)}]})},onEmailInput:function(){if(this.inviteOptions&&this.inviteOptionsForTeams===!0){var t=this.inviteEmail.val().trim(),e=/^[A-Z0-9._%+\-]+@[A-Z0-9.\-]+\.[A-Z]{2,}$/gi.test(t),i=SL.current_team.get("google_domain"),n=e;this.searchTeamMemberEmailCache&&this.searchTeamMemberEmailCache[t]&&(n=!1),n&&i&&t.substring(t.length-i.length,t.length)===i&&(n=!1),this.inviteOptions.toggleClass("hidden",!n)}},onUserClicked:function(t){this.controller.getCurrentDeckUser().isAdmin()&&this.showEditPrompt($(t.currentTarget)),t.preventDefault()},onUserMouseEnter:function(t){var e=$(t.currentTarget),i=e.data("model");if(i){var n=[i.getDisplayName()+'<span class="sl-collab-tooltip-status" data-status="'+i.get("status")+'"></span>','<span style="opacity: 0.70;">'+i.get("email")+"</span>"].join("<br>");SL.tooltip.show(n,{alignment:"l",anchor:e}),e.one("mouseleave",SL.tooltip.hide.bind(SL.tooltip))}},destroy:function(){this.inviteEmailAutocomplete&&this.inviteEmailAutocomplete.destroy(),this.options=null,this.domElement.remove()}}),SL("components").ContextMenu=Class.extend({init:function(t){this.config=$.extend({anchorSpacing:0,minWidth:0,options:[]},t),this.shown=new signals.Signal,this.hidden=new signals.Signal,this.destroyed=new signals.Signal,this.config.anchor=$(this.config.anchor),this.config.anchor.on("contextmenu",this.onContextMenu.bind(this))},setup:function(){this.show=this.show.bind(this),this.hide=this.hide.bind(this),this.layout=this.layout.bind(this),this.onDocumentKeydown=this.onDocumentKeydown.bind(this),this.onDocumentMouseDown=this.onDocumentMouseDown.bind(this),this.domElement=$('<div class="sl-context-menu">'),"function"==typeof this.config.options&&(this.config.options=this.config.options()),this.render(),this.renderList()},render:function(){this.listElement=$('<div class="sl-context-menu-list">').appendTo(this.domElement),this.listElement.css("minWidth",this.config.minWidth+"px")},renderList:function(){this.listElement.empty(),this.config.options.forEach(function(t){if("divider"===t.type)$('<div class="sl-context-menu-divider">').appendTo(this.listElement);else{var e;e="string"==typeof t.url?$('<a class="sl-context-menu-item" href="'+t.url+'">'):$('<div class="sl-context-menu-item">'),e.data("item-data",t),e.html('<span class="label">'+t.label+"</span>"),e.appendTo(this.listElement),e.on("click",function(t){this.hide();var e=$(t.currentTarget).data("item-data").callback;"function"==typeof e&&e.apply(null,[this.contextMenuEvent])}.bind(this)),t.icon&&e.append('<span class="icon i-'+t.icon+'"></span>'),t.shortcut&&e.append('<span class="shortcut">'+t.shortcut+"</span>"),t.attributes&&e.attr(t.attributes)}}.bind(this))},bind:function(){SL.keyboard.keydown(this.onDocumentKeydown),$(document).on("mousedown touchstart pointerdown",this.onDocumentMouseDown)},unbind:function(){SL.keyboard.release(this.onDocumentKeydown),$(document).off("mousedown touchstart pointerdown",this.onDocumentMouseDown)},layout:function(t,e){var i=this.config.anchorSpacing,n=$(window).scrollLeft(),s=$(window).scrollTop(),o=this.domElement.outerWidth(),a=this.domElement.outerHeight(),r=t,l=e-6;t+i+o<window.innerWidth?(this.domElement.attr("data-alignment","r"),r+=i):(this.domElement.attr("data-alignment","l"),r-=o+i),r=Math.min(Math.max(r,n+i),window.innerWidth+n-o-i),l=Math.min(Math.max(l,s+i),window.innerHeight+s-a-i),this.domElement.css({left:r,top:l})},focus:function(t){var e=this.listElement.find(".focus");if(e.length){var i=t>0?e.nextAll(".sl-context-menu-item").first():e.prevAll(".sl-context-menu-item").first();i.length&&(e.removeClass("focus"),i.addClass("focus"))}else this.listElement.find(".sl-context-menu-item").first().addClass("focus")},show:function(){this.rendered||(this.rendered=!0,this.setup()),this.listElement.find(".sl-context-menu-item").each(function(t,e){var i=$(e),n=i.data("item-data");i.toggleClass("hidden","function"==typeof n.filter&&!n.filter())}.bind(this)),this.listElement.find(".sl-context-menu-item:not(.hidden)").length&&(this.domElement.removeClass("visible").appendTo(document.body),setTimeout(function(){this.domElement.addClass("visible")}.bind(this),1),this.bind(),this.layout(this.contextMenuEvent.clientX,this.contextMenuEvent.clientY),this.shown.dispatch(this.contextMenuEvent))},showFor:function(t,e){this.config=$.extend(this.config,t),this.contextMenuEvent=e,this.rendered&&this.renderList(),this.show()},hide:function(){this.listElement.find(".focus").removeClass("focus"),this.domElement.detach(),this.unbind(),this.hidden.dispatch()},isVisible:function(){return this.domElement.parent().length>0},destroy:function(){this.shown.dispose(),this.hidden.dispose(),this.destroyed.dispatch(),this.destroyed.dispose(),this.domElement&&(this.domElement.remove(),this.domElement=null,this.unbind()),this.config=null},onDocumentKeydown:function(t){if(27===t.keyCode)return this.hide(),t.preventDefault(),!1;if(13===t.keyCode){var e=this.listElement.find(".focus");if(e.length)return e.trigger("click"),t.preventDefault(),!1}else{if(38===t.keyCode)return this.focus(-1),t.preventDefault(),!1;if(40===t.keyCode)return this.focus(1),t.preventDefault(),!1;if(9===t.keyCode&&t.shiftKey)return this.focus(-1),t.preventDefault(),!1;if(9===t.keyCode)return this.focus(1),t.preventDefault(),!1}return!0},onContextMenu:function(t){t.preventDefault(),this.contextMenuEvent=t,this.show()},onDocumentMouseDown:function(t){var e=$(t.target);this.isVisible()&&0===e.closest(this.domElement).length&&this.hide()}}),SL("components").Cropper=Class.extend({init:function(t){this.options=$.extend({rect:{x:0,y:0,width:1,height:1},minCropWidth:10,minCropHeight:10},t),this.saved=new signals.Signal,this.closed=new signals.Signal,this.visible=!1,this.scale=1},render:function(){this.rendered||(this.rendered=!0,this.domElement=$('<div class="sl-cropper editing-ui">'),this.innerElement=$('<div class="sl-cropper-inner">').appendTo(this.domElement),this.renderTray(),this.renderAnchors(),this.bind(),this.canvas=document.createElement("canvas"),this.canvas.className="sl-cropper-overlay",this.context=this.canvas.getContext("2d"),this.innerElement.append(this.canvas))},renderTray:function(){this.tray=new SL.components.ModeTray({type:"sl-mode-tray-image-editor",html:['<p class="description">','<span class="icon i-crop title-icon"></span>',"</p>",'<div class="idle-state">','<button class="button save">Done</button></div>','<div class="active-state">','<button class="button save">Save</button><button class="button grey cancel">Cancel</button><button class="button grey reset" data-tooltip="Reset to the original image size" data-tooltip-alignment="b" data-tooltip-oy="6">Reset</button></div>'].join("")}),this.renderSizeInput()},renderSizeInput:function(){this.widthInput=new SL.components.Range({minValue:0,maxValue:9999,unit:"px",width:"64px",style:"tray",progressBar:!1}),this.widthInput.appendTo(this.tray.find(".description")),this.widthInput.changed.add($.throttle(function(t){this.rect.width=parseFloat(t*this.scale)/this.bounds.width,this.rect.x=Math.min(this.rect.x,1-this.rect.width),this.paint(null,!0)}.bind(this),33)),this.heightInput=new SL.components.Range({minValue:0,maxValue:9999,unit:"px",width:"64px",style:"tray",progressBar:!1}),this.heightInput.appendTo(this.tray.find(".description")),this.heightInput.changed.add($.throttle(function(t){this.rect.height=parseFloat(t*this.scale)/this.bounds.height,this.rect.y=Math.min(this.rect.y,1-this.rect.height),this.paint(null,!0)}.bind(this),33))},renderAnchors:function(){this.anchorsElement=$('<div class="anchor-wrapper"><div class="anchor" data-direction="n"></div><div class="anchor" data-direction="e"></div><div class="anchor" data-direction="s"></div><div class="anchor" data-direction="w"></div><div class="anchor" data-direction="nw"><div class="anchor-point"></div></div><div class="anchor" data-direction="ne"><div class="anchor-point"></div></div><div class="anchor" data-direction="se"><div class="anchor-point"></div></div><div class="anchor" data-direction="sw"><div class="anchor-point"></div></div></div>').appendTo(this.innerElement)},bind:function(){this.onDocumentKeydown=this.onDocumentKeydown.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.layout=this.layout.bind(this),this.reset=this.reset.bind(this),this.innerElement.on("vmousedown",this.onMouseDown),this.tray.find(".cancel").on("vclick",this.onCancelClicked.bind(this)),this.tray.find(".save").on("vclick",this.onSaveClicked.bind(this)),this.tray.find(".reset").on("vclick",this.reset)},show:function(t){this.visible===!1&&(this.visible=!0,this.options=$.extend(this.options,t),this.bounds=JSON.parse(JSON.stringify(this.options.imageRect)),this.rect=$.extend({x:0,y:0,width:1,height:1},this.options.cropRect),this.angle=this.options.angle||0,this.render(),this.domElement.appendTo(document.body),this.domElement.addClass("visible"),this.tray.show(this.domElement),this.originalCropRect=this.getCropRectInPixels(),this.load(),this.layout(),window.addEventListener("resize",this.layout),SL.keyboard.keydown(this.onDocumentKeydown))},load:function(){return new Promise(function(t,e){this.imageElement&&this.imageElement.attr("src")===this.options.url?t():(this.imageElement&&this.imageElement.off().remove(),this.imageElement=$('<img class="sl-cropper-image">').appendTo(this.innerElement),this.imageElement.on("load",function(){t()}.bind(this)),this.imageElement.on("error",e),this.imageElement.attr("src",this.options.url))}.bind(this))},hide:function(){this.visible===!0&&(this.visible=!1,this.domElement.detach().removeClass("visible"),this.tray.hide("body"),window.removeEventListener("resize",this.layout),SL.keyboard.release(this.onDocumentKeydown),this.closed.dispatch())},isVisible:function(){return this.visible},reset:function(){this.rect.x=0,this.rect.y=0,this.rect.width=1,this.rect.height=1,this.paint()},saveAndClose:function(){this.saved.dispatch(this.getCropRect()),this.hide()},layout:function(){if(this.scale=1,this.options.anchor&&this.options.anchor.closest(".reveal").length&&(this.scale=Reveal.getScale(),this.bounds.width=Math.round(this.options.imageRect.width*this.scale),this.bounds.height=Math.round(this.options.imageRect.height*this.scale)),this.options.anchor){var t=this.options.anchor.get(0).getBoundingClientRect(),e=this.getCropRectInPixels();this.bounds.x=Math.round(t.left)-e.x,this.bounds.y=Math.round(t.top)-e.y}else this.bounds.x=(window.innerWidth-this.bounds.width)/2,this.bounds.y=(window.innerHeight-this.bounds.height)/2;this.bounds.x=Math.round(this.bounds.x),this.bounds.y=Math.round(this.bounds.y),this.canvas.width=this.bounds.width,this.canvas.height=this.bounds.height,this.imageElement.css({width:this.bounds.width,height:this.bounds.height}),this.paint(e)},paint:function(t,e){t=t||this.getCropRectInPixels();var i=[];i.push("rotate("+this.angle+"deg)"),i=i.join(" ");var n=(this.originalCropRect.x+this.originalCropRect.width/2)*this.scale,s=(this.originalCropRect.y+this.originalCropRect.height/2)*this.scale;this.innerElement.css({left:this.bounds.x,top:this.bounds.y,width:this.bounds.width,height:this.bounds.height,transform:i,transformOrigin:n+"px "+s+"px"}),this.anchorsElement.css({left:t.x,top:t.y,width:t.width,height:t.height}),this.context.fillStyle="rgba(0, 0, 0, 0.7)",this.context.clearRect(0,0,this.bounds.width,this.bounds.height),this.context.fillRect(0,0,this.bounds.width,this.bounds.height),this.context.clearRect(t.x,t.y,t.width,t.height),this.tray.setState(this.isCropped()?"active":""),e||this.updateSizeInput(t)},updateSizeInput:function(){this.widthInput.setMinMaxValue(0,this.bounds.width/this.scale),this.heightInput.setMinMaxValue(0,this.bounds.height/this.scale);var t=this.getCropRectInPixels();this.widthInput.setValue(Math.round(t.width/this.scale)),this.heightInput.setValue(Math.round(t.height/this.scale))},moveCropRegion:function(t,e){t=t?t/this.bounds.width:0,e=e?e/this.bounds.height:0,this.rect.x=Math.min(Math.max(this.rect.x+t,0),1-this.rect.width),this.rect.y=Math.min(Math.max(this.rect.y+e,0),1-this.rect.height),this.paint()},getCropRect:function(){return{x:this.rect.x,y:this.rect.y,width:this.rect.width,height:this.rect.height}},getCropRectInPixels:function(){return{x:this.rect.x*this.bounds.width,y:this.rect.y*this.bounds.height,width:this.rect.width*this.bounds.width,height:this.rect.height*this.bounds.height}},isCropped:function(){return 1!==this.rect.width||1!==this.rect.height},destroy:function(){$(document).off("vmousemove",this.onMouseMove),$(document).off("vmouseup",this.onMouseUp),this.domElement&&this.domElement.remove(),this.saved.dispose(),this.closed.dispose(),SL.keyboard.release(this.onDocumentKeydown)},onMouseDown:function(t){t.preventDefault(),$(document).on("vmousemove",this.onMouseMove),$(document).on("vmouseup",this.onMouseUp),this.mouseDownX=t.clientX,this.mouseDownY=t.clientY,this.anchorDirection=$(t.target).closest(".anchor").attr("data-direction"),this.rectBefore=this.getCropRect()},onMouseMove:function(t){t.preventDefault();var e=t.altKey,i=t.shiftKey,n=t.clientX-this.mouseDownX,s=t.clientY-this.mouseDownY;if(this.angle){var o=SL.util.trig.rotateAround(n,s,0,0,-this.angle);n=o.x,s=o.y}if(this.anchorDirection){n/=this.bounds.width,s/=this.bounds.height,e&&(n*=2,s*=2);var a=this.options.minCropWidth/this.bounds.width,r=this.options.minCropHeight/this.bounds.height,l=1,d=1;if(/n/.test(this.anchorDirection)&&(this.rect.height=this.rectBefore.height-s,e||(d=this.rectBefore.y+this.rectBefore.height)),/e/.test(this.anchorDirection)&&(this.rect.width=this.rectBefore.width+n,e||(l=1-this.rectBefore.x)),/s/.test(this.anchorDirection)&&(this.rect.height=this.rectBefore.height+s,e||(d=1-this.rectBefore.y)),/w/.test(this.anchorDirection)&&(this.rect.width=this.rectBefore.width-n,e||(l=this.rectBefore.x+this.rectBefore.width)),i){var c=l/d,h=this.rectBefore.width/this.rectBefore.height;/s|n/.test(this.anchorDirection)?this.rect.width=this.rect.height*h:this.rect.height=this.rect.width/h,h>c?(l=Math.min(l,this.rect.width),d=l/h):(d=Math.min(d,this.rect.height),l=d*h)}this.rect.width=Math.min(Math.max(this.rect.width,a),l),this.rect.height=Math.min(Math.max(this.rect.height,r),d),e?(this.rect.x=this.rectBefore.x+this.rectBefore.width/2-this.rect.width/2,this.rect.y=this.rectBefore.y+this.rectBefore.height/2-this.rect.height/2,this.rect.x=Math.min(this.rect.x,1-this.rect.width),this.rect.y=Math.min(this.rect.y,1-this.rect.height)):(/n/.test(this.anchorDirection)&&(this.rect.y=this.rectBefore.y+this.rectBefore.height-this.rect.height),/w/.test(this.anchorDirection)&&(this.rect.x=this.rectBefore.x+this.rectBefore.width-this.rect.width),1===this.anchorDirection.length&&(/n|s/.test(this.anchorDirection)?this.rect.x=this.rectBefore.x+(this.rectBefore.width-this.rect.width)/2:/e|w/.test(this.anchorDirection)&&(this.rect.y=this.rectBefore.y+(this.rectBefore.height-this.rect.height)/2))),this.rect.x=Math.max(this.rect.x,0),this.rect.y=Math.max(this.rect.y,0),this.paint()}else this.rect.x=this.rectBefore.x,this.rect.y=this.rectBefore.y,this.rect.width=this.rectBefore.width,this.rect.height=this.rectBefore.height,this.moveCropRegion(n,s)},onMouseUp:function(t){t.preventDefault(),$(document).off("vmousemove",this.onMouseMove),$(document).off("vmouseup",this.onMouseUp),this.anchorDirection=null},onDocumentKeydown:function(t){return 13===t.keyCode?(this.saveAndClose(),t.preventDefault(),!1):!!/input/i.test(t.target.nodeName)||(27===t.keyCode?(this.hide(),t.preventDefault(),!1):37===t.keyCode?(this.moveCropRegion(t.shiftKey?-10:-1,0),t.preventDefault(),!1):39===t.keyCode?(this.moveCropRegion(t.shiftKey?10:1,0),t.preventDefault(),!1):38===t.keyCode?(this.moveCropRegion(0,t.shiftKey?-10:-1),t.preventDefault(),!1):40!==t.keyCode||(this.moveCropRegion(0,t.shiftKey?10:1),t.preventDefault(),!1))},onCancelClicked:function(){this.hide()},onSaveClicked:function(){this.saveAndClose()}}),SL("components").DeckSizePreview=Class.extend({init:function(){this.render(),this.bind(),this.toggle(!1)},render:function(){this.domElement=$(['<div class="sl-deck-size-preview">','<button class="toggle"><span class="icon i-eye"></span></button>','<div class="previews"></div>',"</div>"].join("")),this.toggleElement=this.domElement.find(".toggle"),this.previewsElement=this.domElement.find(".previews"),this.widePreview=this.renderPreview("wide","16:9").appendTo(this.previewsElement),this.tallPreview=this.renderPreview("tall","3:4").appendTo(this.previewsElement)},renderPreview:function(t,e){return $(['<div class="sl-webbrowser no-shadow '+(t||"")+'">','<div class="sl-webbrowser-header">','<div class="sl-webbrowser-header-dot"></div>','<div class="sl-webbrowser-header-dot"></div>','<div class="sl-webbrowser-header-dot"></div>','<div class="sl-webbrowser-header-aspectratio">'+e+"</div>","</div>",'<div class="sl-webbrowser-content">','<div class="sl-webbrowser-slide-background" data-tooltip="Slide background"></div>','<div class="sl-webbrowser-slide-margin"></div>','<div class="sl-webbrowser-slide"><span class="sl-webbrowser-slide-label"></span></div>',"</div>","</div>"].join(""))},bind:function(){this.toggleElement.on("vclick",this.onToggleClicked.bind(this))},toggle:function(t){"bolean"!=typeof t&&(t="collapsed"===this.domElement.attr("data-state")),this.domElement.attr("data-state",t?"expanded":"collapsed"),t&&(SL.util.skipCSSTransitions(this.previewsElement.find(".sl-webbrowser-content"),1),this.refreshPreview(this.widePreview,this.width,this.height,this.margin),this.refreshPreview(this.tallPreview,this.width,this.height,this.margin)),this.isExpanded=t},expandUnlessManuallyClosed:function(){this.isExpanded||this.hasBeenManuallyToggled||this.toggle(!0)},setValue:function(t,e,i){this.width=t,this.height=e,this.margin=i,this.refreshPreview(this.widePreview,t,e,i),this.refreshPreview(this.tallPreview,t,e,i)},refreshPreview:function(t,e,i,n){var s=t.find(".sl-webbrowser-slide").get(0);marginElement=t.find(".sl-webbrowser-slide-margin").get(0),contentElement=t.find(".sl-webbrowser-content").get(0);var o=contentElement.clientWidth,a=contentElement.clientHeight,r=Math.min(o/e,a/i),l=Math.round(e*r),d=Math.round(i*r),c=Math.min(l*n,d*n);marginElement.style.width=l+"px",marginElement.style.height=d+"px",marginElement.style.borderWidth=c/2+"px",s.style.width=l-c+"px",s.style.height=d-c+"px",s.querySelector(".sl-webbrowser-slide-label").textContent="Slide\n"+e+"x"+i,marginElement.setAttribute("data-tooltip",100*n+"% margin")},onToggleClicked:function(t){this.hasBeenManuallyToggled=!0,t.preventDefault(),this.toggle()}}),SL("components.decksharer").DeckSharer=SL.components.popup.Popup.extend({TYPE:"decksharer",MODE_PUBLIC:{id:"public",width:560},MODE_UPGRADE_OR_PUBLISH:{id:"upgrade-or-publish",width:800},MODE_PRIVATE:{id:"private",width:800},MODE_INTERNAL:{id:"internal",width:560},init:function(t){var e=t.deck,i=e.belongsTo(SL.current_user);i&&(e.isVisibilitySelf()||e.isVisibilityTeam())&&!SL.current_user.privileges.privateLinks()?this.mode=this.MODE_UPGRADE_OR_PUBLISH:i&&(e.isVisibilitySelf()||e.isVisibilityTeam())?this.mode=this.MODE_PRIVATE:!i&&e.isVisibilityTeam()?this.mode=this.MODE_INTERNAL:this.mode=this.MODE_PUBLIC,this._super($.extend({title:"Share",titleItem:'"'+e.get("title")+'"',width:this.mode.width},t))},switchMode:function(t){this.mode=t,this.bodyElement.empty(),this.renderMode(),this.options.width=this.mode.width,this.layout()},render:function(){this._super(),this.renderMode()},renderMode:function(){this.mode.id===this.MODE_UPGRADE_OR_PUBLISH.id?this.renderUpgradeOrPublish():this.mode.id===this.MODE_PRIVATE.id?this.renderPrivate():this.mode.id===this.MODE_INTERNAL.id?this.renderInternal():this.renderPublic()},renderPublic:function(){this.shareOptions=new SL.components.decksharer.ShareOptions(this.options.deck,this.options),this.shareOptions.pageChanged.add(this.layout.bind(this)),this.shareOptions.appendTo(this.bodyElement)},renderInternal:function(){this.bodyElement.append('<p class="decksharer-share-warning">This deck is internal and can only be shared with and viewed by other team members.</p>'),this.shareOptions=new SL.components.decksharer.ShareOptions(this.options.deck,$.extend(this.options,{embedEnabled:!1})),this.shareOptions.pageChanged.add(this.layout.bind(this)),this.shareOptions.appendTo(this.bodyElement)},renderPrivate:function(){this.domElement.attr("data-content-state","loading"),this.placeholderElement=$(['<div class="decksharer-placeholder">','<div class="decksharer-placeholder-inner">','<div class="spinner" data-spinner-color="#999"></div>',"</div>","</div>"].join("")),this.placeholderElement.appendTo(this.bodyElement),SL.util.html.generateSpinners(),SL.data.tokens.get(this.options.deck.get("id"),{success:function(t){this.tokens=t,this.tokenList=new SL.components.decksharer.TokenList(this.options.deck,this.tokens),this.tokenList.appendTo(this.bodyElement),this.tokenList.tokenSelected.add(this.onTokenSelected.bind(this)),this.tokenList.tokensEmptied.add(this.onTokensEmptied.bind(this)),this.domElement.removeAttr("data-content-state"),0===this.tokens.size()?this.renderTokenPlaceholder():this.tokenList.selectDefault()}.bind(this),error:function(t){this.destroy(),401===t?SL.notify("It looks like you're no longer signed in to Slides. Please open a new tab and sign in.","negative"):SL.notify(SL.locale.get("GENERIC_ERROR"),"negative")}.bind(this)})},renderUpgradeOrPublish:function(){this.domElement.attr("data-content-state","placeholder"),this.placeholderElement=$(['<div class="decksharer-placeholder">','<div class="decksharer-placeholder-inner">','<div class="left">','<div class="lock-icon icon i-lock-stroke"></div>',"</div>",'<div class="right">',"<h3>Upgrade required</h3>","<p>You can't share privately on your current plan. Please upgrade your account to gain access to private links, password protection and more.</p>",'<a class="button upgrade-button l" href="'+SL.routes.PRICING+'">View upgrade options</a>','<button class="button publish-button ladda-button l light-grey" data-style="zoom-out" data-spinner-color="#222">Make deck public</button>',"</div>","</div>","</div>"].join("")),this.placeholderElement.appendTo(this.bodyElement);var t=this.placeholderElement.find(".publish-button");t.on("vclick",function(){$.ajax({type:"POST",url:SL.endpoints.PUBLISH_DECK(this.options.deck.get("id")),context:this,data:{visibility:SL.models.Deck.VISIBILITY_ALL}}).then(function(){this.domElement.removeAttr("data-content-state");var e=t.data("data");e&&e.stop(),this.options.deck.set("visibility",SL.models.Deck.VISIBILITY_ALL),this.switchMode(this.MODE_PUBLIC),SL.notify("Published successfully")},function(){var e=t.data("data");e&&e.stop(),SL.notify(SL.locale.get("GENERIC_ERROR"),"negative")})}.bind(this)),Ladda.bind(t.get(0))},resetContentArea:function(){this.tokenOptions&&(this.tokenOptions.destroy(),this.tokenOptions=null),this.placeholderElement&&(this.placeholderElement.addClass("hidden"),setTimeout(this.placeholderElement.remove.bind(this.placeholderElement),300),this.placeholderElement=null)},renderTokenPlaceholder:function(){this.domElement.attr("data-content-state","placeholder"),this.resetContentArea();var t=this.options.deck.isVisibilityTeam()?"This deck is internal":"This deck is private";this.placeholderElement=$(['<div class="decksharer-placeholder">','<div class="decksharer-placeholder-inner">','<div class="left">','<div class="lock-icon icon i-lock-stroke"></div>',"</div>",'<div class="right">',"<h3>"+t+"</h3>","<p>To share it you'll need to create a private link.</p>",'<button class="button create-button xl ladda-button" data-style="zoom-out">Create private link</button>',"</div>","</div>","</div>"].join("")),this.placeholderElement.appendTo(this.bodyElement),this.placeholderElement.find(".create-button").on("vclick",function(){this.tokenList.create()}.bind(this)),Ladda.bind(this.placeholderElement.find(".create-button").get(0)),this.layout()},renderTokenOptions:function(t){this.domElement.removeAttr("data-content-state");var e=!this.tokenOptions;this.resetContentArea(),this.tokenOptions=new SL.components.decksharer.TokenOptions(this.options.deck,t,this.options),this.tokenOptions.appendTo(this.bodyElement,e),this.tokenOptions.tokenRenamed.add(this.tokenList.setTokenLabel.bind(this.tokenList)),this.tokenOptions.shareOptions.pageChanged.add(this.layout.bind(this)),this.layout()},onTokenSelected:function(t){this.renderTokenOptions(t)},onTokensEmptied:function(){this.renderTokenPlaceholder()},destroy:function(){this.shareOptions&&(this.shareOptions.destroy(),this.shareOptions=null),this.tokenList&&(this.tokenList.destroy(),this.tokenList=null),this.options.deck=null,this.tokens=null,this._super()}}),SL("components.decksharer").ShareOptions=Class.extend({USE_READONLY:!SL.util.device.IS_PHONE&&!SL.util.device.IS_TABLET,init:function(t,e){this.deck=t,this.options=$.extend({token:null,linkEnabled:!0,embedEnabled:!0,emailEnabled:!0},e),this.onLinkInputMouseDown=this.onLinkInputMouseDown.bind(this),this.onEmbedOutputMouseDown=this.onEmbedOutputMouseDown.bind(this),this.onEmbedStyleChanged=this.onEmbedStyleChanged.bind(this),this.onEmbedSizeChanged=this.onEmbedSizeChanged.bind(this),this.onEmbedOptionChanged=this.onEmbedOptionChanged.bind(this),this.saveEmbedWhitelistThrottled=$.debounce(this.saveEmbedWhitelist.bind(this),1500,!1),this.width=SL.components.decksharer.ShareOptions.DEFAULT_WIDTH,this.height=SL.components.decksharer.ShareOptions.DEFAULT_HEIGHT,this.style="",this.pageChanged=new signals.Signal,this.render(),this.generate()},render:function(){this.domElement=$('<div class="decksharer-share-options">'),this.tabsElement=$('<div class="decksharer-share-options-tabs">').appendTo(this.domElement),this.pagesElement=$('<div class="decksharer-share-options-pages">').appendTo(this.domElement),this.options.deckView?(this.tabsElement.hide(),this.renderDeckViewLink(),this.showPage(SL.components.decksharer.ShareOptions.LINK_PAGE_ID)):(this.options.linkEnabled&&this.renderLink(),this.options.embedEnabled&&this.renderEmbed(),this.options.emailEnabled&&SL.util.user.isLoggedIn()&&this.renderEmail(),this.tabsElement.find(".decksharer-share-options-tab").on("vclick",function(t){var e=$(t.currentTarget).attr("data-id");this.showPage(e),SL.analytics.track("Decksharer: Tab clicked",e)}.bind(this)),this.showPage(this.tabsElement.find(".decksharer-share-options-tab").first().attr("data-id")))},renderLink:function(){this.tabsElement.append('<div class="decksharer-share-options-tab" data-id="'+SL.components.decksharer.ShareOptions.LINK_PAGE_ID+'">Copy Link</div>'),this.pagesElement.append(['<div class="decksharer-share-options-page sl-form" data-id="link">','<div class="unit link-unit">',"<label>Link URL</label>","</div>","</div>"].join("")),this.renderLinkInput();var t=this.pagesElement.find(".decksharer-share-options-page");t.append('<p class="form-label">Link options</p>'),this.canDeeplink()&&(t.append(['<div class="unit sl-checkbox outline">','<input id="link-deeplink-checkbox" type="checkbox" class="link-deeplink-input" />','<label for="link-deeplink-checkbox">Link to current slide</label>',"</div>"].join("")),this.linkDeeplinkInput=this.pagesElement.find('[data-id="link"] .link-deeplink-input'),this.linkDeeplinkInput.on("change",this.onDeeplinkToggled.bind(this))),t.append(['<div class="unit sl-checkbox outline fullscreen-unit">','<input id="fullscreen-checkbox" type="checkbox" class="fullscreen-input" />','<label for="fullscreen-checkbox">Fullscreen</label>',"</div>"].join("")),this.fullscreenInput=this.pagesElement.find('[data-id="link"] .fullscreen-input'),this.fullscreenInput.on("change",this.onLinkFullscreenToggled.bind(this)),2===t.find(".sl-checkbox").length&&t.append($('<div class="half-units">').append(t.find(".sl-checkbox")))},renderLinkInput:function(){this.USE_READONLY?(this.linkInput=$('<input type="text" class="link-input" readonly="readonly" />'),this.linkInput.on("mousedown",this.onLinkInputMouseDown),this.linkInput.appendTo(this.pagesElement.find('[data-id="link"] .link-unit'))):(this.linkAnchor=$('<a href="#" class="input-field">'),this.linkAnchor.appendTo(this.pagesElement.find('[data-id="link"] .link-unit')))},renderDeckViewLink:function(){this.pagesElement.append(['<div class="decksharer-share-options-page sl-form" data-id="link">','<div class="unit link-unit">',"<label>Presentation link</label>","</div>","</div>"].join("")),"live"===this.options.deckView?(this.pagesElement.find('[data-id="link"] .link-unit label').text("Live presentation link"),this.pagesElement.find('[data-id="link"] .link-unit').append('<p class="unit-description">This links lets viewers follow the presentation in real-time.</p>')):"presenter"===this.options.deckView&&(this.pagesElement.find('[data-id="link"] .link-unit label').text("Presenter URL"),this.pagesElement.find('[data-id="link"] .link-unit').append('<p class="unit-description">Share this link with someone to let them present the deck. Presenters will also be able to access speaker notes, if there are any.</p>')),this.renderLinkInput()},renderEmbed:function(){this.tabsElement.append('<div class="decksharer-share-options-tab" data-id="'+SL.components.decksharer.ShareOptions.EMBED_PAGE_ID+'">Embed</div>');var t='<option value="dark" selected>Dark</option><option value="light">Light</option>';this.options.deck.user.privileges.hideEmbedFooter()&&(t+='<option value="hidden">Hidden</option>'),this.pagesElement.append(['<div class="decksharer-share-options-page sl-form" data-id="embed">','<div class="embed-options">','<div class="unit width">',"<label>Width:</label>",'<input type="text" name="width" maxlength="4" />',"</div>",'<div class="unit height">',"<label>Height:</label>",'<input type="text" name="height" maxlength="4" />',"</div>",'<div class="unit footer-style">',"<label>Footer style:</label>",'<select class="sl-select" name="style">',t,"</select>","</div>","</div>",'<div class="embed-extra-options"></div>','<p class="form-label">Embed code:</p>','<div class="embed-output-wrapper">','<div class="embed-output">','<textarea name="output"></textarea>',"</div>",'<div class="embed-actions">','<button class="button s light-grey copy-embed-code" data-tooltip-alignment="r" data-tooltip="Copy to clipboard"><span class="icon i-content_copy"></span></button>','<button class="button s light-grey preview-embed-code" data-tooltip-alignment="r" data-tooltip="Preview"><span class="icon i-eye"></span></button>',"</div>","</div>","</div>"].join("")),
this.embedElement=this.pagesElement.find('[data-id="embed"]'),this.embedElement.find(".copy-embed-code").on("vclick",function(){SL.util.copyToClipboard(this.embedOutputElement.text()),SL.notify("Copied embed code to clipboard!")}.bind(this)),this.embedElement.find(".preview-embed-code").on("vclick",function(){SL.popup.openOne(SL.components.popup.PreviewMedia,{mediaType:"iframe",mediaURL:this.embedURL,mediaWidth:this.width,mediaHeight:this.height,titleItem:"Embed"})}.bind(this)),this.options.deck.user.privileges.hideEmbedFooter()&&this.options.deck.isVisibilityAll()&&($(['<p class="form-label">Embed options:</p>','<div class="unit sl-checkbox outline">','<input id="embed-byline-checkbox" type="checkbox" class="embed-hide-byline-input" />','<label for="embed-byline-checkbox">Hide byline</label>',"</div>",'<div class="unit sl-checkbox outline">','<input id="embed-share-checkbox" type="checkbox" class="embed-hide-share-input" />','<label for="embed-share-checkbox">Hide share button</label>',"</div>"].join("")).appendTo(this.embedElement.find(".embed-extra-options")),this.embedHideBylineInput=this.embedElement.find(".embed-hide-byline-input"),this.embedHideShareInput=this.embedElement.find(".embed-hide-share-input"),this.embedHideBylineInput.on("change",this.onEmbedOptionChanged),this.embedHideShareInput.on("change",this.onEmbedOptionChanged)),this.options.deck.user.privileges.embedWhitelist()&&this.options.token&&($(['<div class="unit">',"<label>Restrict where this deck is embedded</label>",'<p class="unit-description">',"Set a domain to limit where this can be embedded. Empty means unrestricted.","</p>",'<input type="text" name="embed-domain-whitelist" class="embed-domain-whitelist" maxlength="512" placeholder="example.com" />',"</div>"].join("")).appendTo(this.embedElement.find(".embed-extra-options")),this.embedDomainInput=this.embedElement.find(".embed-domain-whitelist"),this.embedDomainInput.on("blur",function(){this.formatEmbedWhitelist(!0),this.saveEmbedWhitelist()}.bind(this)),this.embedDomainInput.on("input",this.saveEmbedWhitelistThrottled),this.embedDomainInput.val(this.options.token.get("embed_domain_whitelist"))),SL.current_user.get("id")===this.options.deck.user.get("id")&&this.options.deck.user.privileges.hideEmbedFooter()===!1&&this.embedElement.append(['<a class="button outline thin embed-upgrade-promotion" href="'+SL.routes.PRICING+'">',"Upgrade to remove Slides branding from your embeds, restrict where your presentations can be embedded, and much more","</a>"].join("")),this.canDeeplink()&&($(['<div class="unit sl-checkbox outline">','<input id="embed-deeplink-checkbox" type="checkbox" class="embed-deeplink-input" />','<label for="embed-deeplink-checkbox">Start embed on current slide</label>',"</div>"].join("")).appendTo(this.embedElement.find(".embed-extra-options")),this.embedDeeplinkInput=this.embedElement.find(".embed-deeplink-input"),this.embedDeeplinkInput.on("change",this.onEmbedOptionChanged)),this.embedStyleElement=this.embedElement.find("select[name=style]"),this.embedWidthElement=this.embedElement.find("input[name=width]"),this.embedHeightElement=this.embedElement.find("input[name=height]"),this.embedOutputElement=this.embedElement.find("textarea"),this.embedStyleElement.on("change",this.onEmbedStyleChanged),this.embedWidthElement.on("input",this.onEmbedSizeChanged),this.embedHeightElement.on("input",this.onEmbedSizeChanged),this.USE_READONLY?(this.embedOutputElement.attr("readonly","readonly"),this.embedOutputElement.on("mousedown",this.onEmbedOutputMouseDown)):this.embedOutputElement.on("input",this.generate.bind(this)),this.embedWidthElement.val(this.width),this.embedHeightElement.val(this.height)},renderEmail:function(){this.tabsElement.append('<div class="decksharer-share-options-tab" data-id="'+SL.components.decksharer.ShareOptions.EMAIL_PAGE_ID+'">Email</div>'),this.pagesElement.append(['<div class="decksharer-share-options-page" data-id="email">','<div class="sl-form">','<div class="unit" data-validate="none" data-required>',"<label>From</label>",'<input type="text" class="email-from" placeholder="Your Name" maxlength="255" />',"</div>",'<div class="unit" data-validate="none" data-required>',"<label>To</label>",'<input type="text" class="email-to" placeholder="john@example.com, jane@example.com" maxlength="2500" />',"</div>",'<div class="unit text" data-validate="none" data-required>',"<label>Message</label>",'<p class="unit-description">A link to the deck is automatically included after the message.</p>','<textarea class="email-body" rows="3" maxlength="2500"></textarea>',"</div>",'<div class="submit-wrapper">','<button type="submit" class="button positive l ladda-button email-submit" data-style="zoom-out">Send</button>',"</div>","</div>",'<div class="email-success">','<div class="email-success-icon icon i-checkmark"></div>','<p class="email-success-description">Email sent!</p>',"</div>","</div>"].join("")),this.emailElement=this.pagesElement.find('[data-id="email"]'),this.emailSuccess=this.emailElement.find(".email-success"),this.emailForm=this.emailElement.find(".sl-form"),this.emailFromElement=this.emailForm.find(".email-from"),this.emailToElement=this.emailForm.find(".email-to"),this.emailBodyElement=this.emailForm.find(".email-body"),this.emailSubmitButton=this.emailForm.find(".email-submit"),this.emailFormUnits=[],this.emailForm.find(".unit[data-validate]").each(function(t,e){this.emailFormUnits.push(new SL.components.FormUnit(e))}.bind(this)),this.emailSubmitButton.on("vclick",this.onEmailSubmitClicked.bind(this)),this.emailSubmitLoader=Ladda.create(this.emailSubmitButton.get(0))},appendTo:function(t){this.domElement.appendTo(t)},showPage:function(t){this.tabsElement.find(".decksharer-share-options-tab").removeClass("is-selected"),this.pagesElement.find(".decksharer-share-options-page").removeClass("is-selected"),this.tabsElement.find('[data-id="'+t+'"]').addClass("is-selected"),this.pagesElement.find('[data-id="'+t+'"]').addClass("is-selected"),this.pageChanged.dispatch(t)},getPageID:function(){return this.tabsElement.find(".is-selected").attr("data-id")},generate:function(){var t=this.getShareURLs();this.embedURL=t.embed;var e=window.Reveal&&window.Reveal.isReady()?window.Reveal.getIndices():null;if(e&&this.embedDeeplinkInput&&this.embedDeeplinkInput.is(":checked")&&(e.v>0?this.embedURL+="#/"+e.h+"/"+e.v:e.h>0&&(this.embedURL+="#/"+e.h)),this.embedOutputElement){var i='<iframe src="'+this.embedURL+'" width="'+this.width+'" height="'+this.height+'" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';this.embedOutputElement.text(i)}var n=this.fullscreenInput&&this.fullscreenInput.is(":checked")?t.fullscreen:t.show;e&&this.linkDeeplinkInput&&this.linkDeeplinkInput.is(":checked")&&(e.v>0?n+="#/"+e.h+"/"+e.v:e.h>0&&(n+="#/"+e.h)),this.linkInput&&this.linkInput.val(n),this.linkAnchor&&this.linkAnchor.attr("href",n).text(n),this.emailElement&&(SL.current_user&&this.emailFromElement.val(SL.current_user.getNameOrSlug()),this.deck.has("title")&&"deck"!==this.deck.get("title")?this.emailBodyElement.val('Check out this deck "'+this.deck.get("title")+'"'):this.emailBodyElement.val("Check out this deck"))},getShareURLs:function(){var t="https:",e={show:this.deck.getURL({protocol:t,view:this.options.deckView}),fullscreen:this.deck.getURL({protocol:t,view:"fullscreen"}),embed:this.deck.getURL({protocol:t,view:"embed"})},i=[];return this.options.token&&this.options.token.has("token")&&i.push("token="+this.options.token.get("token")),e.show+=i.length?"?"+i.join("&"):"",e.fullscreen+=i.length?"?"+i.join("&"):"","string"==typeof this.style&&this.style.length>0&&i.push("style="+this.style),this.embedHideBylineValue===!0&&i.push("byline=hidden"),this.embedHideShareValue===!0&&i.push("share=hidden"),e.embed+=i.length?"?"+i.join("&"):"",e},canDeeplink:function(){var t=window.Reveal&&window.Reveal.isReady()?window.Reveal.getIndices():null;return t&&(t.h>0||t.v>0)},formatEmbedWhitelist:function(t){var e=this.embedDomainInput.val();return e=e.trim(),e=e.replace(/[^a-zA-Z0-9:%\.\/\-\_\#]/g,""),t===!0&&this.embedDomainInput.val(e),e},saveEmbedWhitelist:function(){var t=this.formatEmbedWhitelist();t!==this.options.token.get("embed_domain_whitelist")&&(this.options.token.set("embed_domain_whitelist",this.embedDomainInput.val()),this.options.token.save(["embed_domain_whitelist"]).fail(function(){SL.notify("Failed to save embed restriction","negative")}.bind(this)).done(function(){SL.notify("Embed restriction saved"),this.domElement.removeClass("is-unsaved")}.bind(this)))},onEmbedOutputMouseDown:function(t){t.preventDefault(),this.embedOutputElement.focus().select(),SL.analytics.track("Decksharer: Embed code selected")},onLinkInputMouseDown:function(t){t.preventDefault(),$(t.target).focus().select(),SL.analytics.track("Decksharer: URL selected")},onDeeplinkToggled:function(){this.generate(),SL.analytics.track("Decksharer: Deeplink toggled")},onLinkFullscreenToggled:function(){this.generate(),SL.analytics.track("Decksharer: URL fullscreen toggled")},onEmbedSizeChanged:function(){this.width=parseInt(this.embedWidthElement.val(),10)||1,this.height=parseInt(this.embedHeightElement.val(),10)||1,this.generate()},onEmbedStyleChanged:function(){this.style=this.embedStyleElement.val(),this.generate()},onEmbedOptionChanged:function(){this.embedHideBylineInput&&(this.embedHideBylineValue=this.embedHideBylineInput.is(":checked")),this.embedHideShareInput&&(this.embedHideShareValue=this.embedHideShareInput.is(":checked")),this.generate()},onEmailSubmitClicked:function(t){var e=this.emailFormUnits.every(function(t){return t.beforeSubmit()});if(e&&!this.emailXHR){SL.analytics.track("Decksharer: Submit email");var i=this.emailFromElement.val(),n=this.emailToElement.val(),s=this.emailBodyElement.val();this.emailSubmitLoader.start(),n=n.split(","),n=n.map(function(t){return t.trim()}),n=n.join(",");var o={deck_share:{emails:n,from:i,body:s}};this.options.token&&(o.deck_share.access_token_id=this.options.token.get("id")),this.emailXHR=$.ajax({url:SL.endpoints.SHARE_DECK_VIA_EMAIL(this.deck.get("id")),type:"POST",context:this,data:o}).done(function(){this.emailSuccess.addClass("visible"),setTimeout(function(){this.emailSuccess.removeClass("visible"),this.emailToElement.val(""),this.emailBodyElement.val(""),this.generate()}.bind(this),3e3),SL.analytics.track("Decksharer: Submit email success")}).fail(function(){SL.notify("Failed to send email","negative"),SL.analytics.track("Decksharer: Submit email error")}).always(function(){this.emailXHR=null,this.emailSubmitLoader.stop()})}t.preventDefault()},destroy:function(){this.pageChanged.dispose(),this.deck=null,this.domElement.remove()}}),SL.components.decksharer.ShareOptions.DEFAULT_WIDTH=576,SL.components.decksharer.ShareOptions.DEFAULT_HEIGHT=420,SL.components.decksharer.ShareOptions.LINK_PAGE_ID="link",SL.components.decksharer.ShareOptions.EMBED_PAGE_ID="embed",SL.components.decksharer.ShareOptions.EMAIL_PAGE_ID="email",SL("components.decksharer").TokenList=Class.extend({init:function(t,e){this.deck=t,this.tokens=e,this.tokenSelected=new signals.Signal,this.tokensEmptied=new signals.Signal,this.render()},render:function(){this.domElement=$('<div class="decksharer-token-list">'),this.listItems=$('<div class="decksharer-token-list-items">').appendTo(this.domElement),this.createButton=$(['<div class="decksharer-token-list-create ladda-button" data-style="zoom-out" data-spinner-color="#222">','<span class="icon i-plus"></span>',"</div>"].join("")),this.createButton.on("vclick",this.create.bind(this)),this.createButton.appendTo(this.domElement),this.createButtonLoader=Ladda.create(this.createButton.get(0)),this.tokens.forEach(this.renderToken.bind(this)),this.scrollShadow=new SL.components.ScrollShadow({parentElement:this.domElement,contentElement:this.listItems,footerElement:this.createButton,resizeContent:!1})},renderToken:function(t){var e=t.get("deck_view_count")||0,i=e+" "+SL.util.string.pluralize("view","s",1!==e),n=$(['<div class="decksharer-token-list-item" data-id="'+t.get("id")+'">','<span class="label"></span>','<div class="meta">','<span class="views">'+i+"</span>",'<span class="icon i-trash delete" data-tooltip="Delete link"></span>',"</div>","</div>"].join(""));n.appendTo(this.listItems),n.on("vclick",function(e){if($(e.target).closest(".delete").length>0){SL.prompt({anchor:n,alignment:"r",title:"Are you sure you want to delete this link? It will stop working for anyone you have already shared it with.",type:"select",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Delete</h3>",selected:!0,className:"negative",callback:function(){this.remove(t,n)}.bind(this)}]})}else this.select(t)}.bind(this)),this.setTokenLabel(t)},setTokenLabel:function(t,e){var i=this.listItems.find(".decksharer-token-list-item[data-id="+t.get("id")+"]");i.length&&(e||(e=t.get("name")||t.get("token")),i.find(".label").html(e))},appendTo:function(t){this.domElement.appendTo(t),this.scrollShadow.sync()},selectDefault:function(){this.select(this.tokens.first()),this.scrollShadow.sync()},select:function(t){if(t&&t!==this.selectedToken){var e=this.listItems.find(".decksharer-token-list-item[data-id="+t.get("id")+"]");e.length&&(this.listItems.find(".decksharer-token-list-item").removeClass("is-selected"),e.addClass("is-selected"),this.tokenSelected.dispatch(t),this.selectedToken=t)}},create:function(t){var e=0===this.tokens.size();t&&this.createButtonLoader.start(),SL.data.tokens.create(this.deck.get("id")).then(function(t){e?SL.analytics.track("Decksharer: Created first token"):SL.analytics.track("Decksharer: Created additional token"),this.renderToken(t),this.select(t),this.createButtonLoader.stop(),this.scrollShadow.sync()}.bind(this),function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative"),this.createButtonLoader.stop()}.bind(this))},remove:function(t,e){t.destroy().fail(function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative")}.bind(this)).done(function(){SL.util.anim.collapseListItem(e,function(){e.remove(),this.scrollShadow.sync()}.bind(this),300),this.tokens.remove(t),this.selectedToken===t&&(this.selectedToken=null,this.selectDefault()),0===this.tokens.size()&&this.tokensEmptied.dispatch(),SL.analytics.track("Decksharer: Deleted token")}.bind(this))},destroy:function(){this.createButtonLoader&&this.createButtonLoader.stop(),this.scrollShadow&&this.scrollShadow.destroy(),this.tokens=null,this.domElement.remove()}}),SL("components.decksharer").TokenOptions=Class.extend({init:function(t,e,i){this.deck=t,this.token=e,this.options=i,this.tokenRenamed=new signals.Signal,this.render(),this.bind()},render:function(){this.domElement=$('<div class="decksharer-token-options">'),this.innerElement=$('<div class="sl-form decksharer-token-options-inner">'),this.innerElement.appendTo(this.domElement),this.renderNameAndPassword(),this.renderNotification(),this.renderLinkType(),this.renderShareOptions()},renderNameAndPassword:function(){this.namePasswordElement=$('<div class="split-units">'),this.namePasswordElement.appendTo(this.innerElement),this.namePasswordElement.append('<input name="dummyusername" type="text" style="display:none;"><input name="dummyuassword" type="password" style="display:none;">'),this.nameUnit=$(['<div class="unit">','<label class="form-label" for="token-name">Name</label>','<p class="unit-description">So you can tell your links apart.</p>','<input class="input-field" type="text" id="token-name" maxlength="255" autocomplete="off" />',"</div>"].join("")),this.nameUnit.appendTo(this.namePasswordElement),this.nameInput=this.nameUnit.find("input"),this.nameInput.val(this.token.get("name")),this.passwordUnit=$(['<div class="unit">','<label class="form-label" for="token-password">Password<span class="optional-label">- optional</span></label>','<p class="unit-description">Viewers need to enter this.</p>','<input class="input-field" type="password" id="token-password" placeholder="&bull;&bull;&bull;&bull;&bull;&bull;" maxlength="255" autocomplete="off" />',"</div>"].join("")),this.passwordUnit.appendTo(this.namePasswordElement),this.passwordInput=this.passwordUnit.find("input"),this.passwordInput.val(this.token.get("password"))},renderNotification:function(){this.notificationUnit=$(['<div class="unit sl-checkbox outline notification-unit">','<input id="notification-checkbox" type="checkbox" class="notification-input" />','<label for="notification-checkbox">Notify me via email the first time this link is opened</label>',"</div>"].join("")),this.notificationUnit.appendTo(this.innerElement),this.notificationInput=this.notificationUnit.find(".notification-input"),this.notificationInput.prop("checked",this.token.get("notify_on_view")),this.token.get("deck_view_count")>0&&this.notificationUnit.hide()},renderLinkType:function(){var t="presenter"===this.token.get("link_type"),e=this.deck.belongsTo(SL.current_user)&&SL.current_user.isEnterprise();this.linkTypeUnit=$(['<div class="unit radio link-type-unit">','<label class="form-label">Link type</label>','<div class="link-type-options">','<input type="radio" name="link-type" value="view" id="link-type-1" '+(t?"":"checked")+">",'<label class="link-type-radio radio-subtle" for="link-type-1">','Viewer link<span class="optional-label">- default</span>','<p class="radio-description">',"Anyone with the link can view the presentation.","</p>","</label>",'<input type="radio" name="link-type" value="presenter" id="link-type-2" '+(t?"checked":"")+">",'<label class="link-type-radio radio-subtle" for="link-type-2">',"Presenter link",'<p class="radio-description">',"Anyone with the link can present and see speaker notes.","</p>","</label>","</div>","</div>"].join("")),this.linkTypeUnit.appendTo(this.innerElement),this.linkTypeUnit.find('input[name="link-type"]').on("change",this.onLinkTypeChange.bind(this)),"live"!==this.options.deckView&&e||this.linkTypeUnit.remove()},renderShareOptions:function(){this.shareOptions&&this.shareOptions.destroy();var t=this.options.deckView;t||(t="presenter"===this.token.get("link_type")?"presenter":null),this.shareOptions=new SL.components.decksharer.ShareOptions(this.deck,$.extend({token:this.token,deckView:t},this.options)),this.shareOptions.appendTo(this.domElement)},bind:function(){this.saveChanges=this.saveChanges.bind(this),this.nameInput.on("input",this.onNameInput.bind(this)),this.nameInput.on("change",this.onNameChange.bind(this)),this.passwordInput.on("change",this.onPasswordChange.bind(this)),this.passwordInput.on("input",this.onPasswordInput.bind(this)),this.notificationInput.on("change",this.onNotificationChange.bind(this))},appendTo:function(t,e){this.domElement.appendTo(t),e||SL.util.dom.calculateStyle(this.domElement)},checkUnsavedChanges:function(){clearTimeout(this.checkUnsavedChangesTimeout);var t=this.token.get("name")||"",e=this.token.get("password")||"",i=this.token.get("link_type"),n=this.token.get("notify_on_view")||!1,s=this.nameInput.val(),o=this.passwordInput.val(),a=this.linkTypeUnit.find("input[type=radio]:checked").val(),r=this.notificationInput.is(":checked"),l=o!==e||s!==t||a!==i||r!==n;l&&this.saveChanges()},checkUnsavedChangesThrottled:function(){clearTimeout(this.checkUnsavedChangesTimeout),this.checkUnsavedChangesTimeout=setTimeout(this.checkUnsavedChanges.bind(this),1e3)},saveChanges:function(){clearTimeout(this.checkUnsavedChangesTimeout),this.token.set("name",this.nameInput.val()||"Untitled"),this.token.set("password",this.passwordInput.val()),this.token.set("link_type",this.linkTypeUnit.find("input[type=radio]:checked").val()),this.token.set("notify_on_view",this.notificationInput.is(":checked")),this.token.save(["name","password","notify_on_view","link_type"]).fail(function(){SL.notify("Unable to save link settings.","negative")}.bind(this)).done(function(){SL.notify("Link changes saved"),this.domElement.removeClass("is-unsaved")}.bind(this))},onNameInput:function(){this.tokenRenamed.dispatch(this.token,this.nameInput.val()),this.checkUnsavedChangesThrottled()},onNameChange:function(){this.checkUnsavedChanges()},onPasswordInput:function(){this.checkUnsavedChangesThrottled()},onPasswordChange:function(){this.checkUnsavedChanges()},onNotificationChange:function(){this.checkUnsavedChanges()},onLinkTypeChange:function(){this.checkUnsavedChanges(),this.renderShareOptions()},destroy:function(){this.tokenRenamed.dispatch(this.token),this.tokenRenamed.dispose(),this.shareOptions&&(this.shareOptions.destroy(),this.shareOptions=null),this.deck=null,this.token=null,this.domElement.addClass("hidden"),this.domElement.remove()}}),SL("components").EasingList=Class.extend({init:function(t){this.config=$.extend({items:SL.config.EASING_EQUATIONS,className:"",defaultID:"ease",thumbTransitionSeconds:1},t),this.selectionChanged=new signals.Signal,this.render(),this.bind()},render:function(){this.domElement=$('<div class="sl-easing-list"></div>'),this.domElement.addClass(this.config.className),this.config.items.forEach(this.renderListItem.bind(this))},renderListItem:function(t){var e={};e.wrapper=document.createElement("button"),e.wrapper.classList.add("sl-easing-thumbnail"),e.wrapper.setAttribute("data-value",t.value),e.wrapper.setAttribute("data-title",t.title),e.thumb=document.createElement("div"),e.thumb.classList.add("thumb"),e.wrapper.appendChild(e.thumb),e.label=document.createElement("p"),e.label.classList.add("label"),e.label.textContent=t.title,e.wrapper.appendChild(e.label),"string"==typeof this.config.defaultID&&this.config.defaultID===t.value&&(e.label.innerHTML+='<span class="icon i-star" data-tooltip="The default setting"></span>'),e.thumb.innerHTML='<svg width="100%" height="100%" viewBox="-15 -15 130 130"><path fill="none" d="'+t.path+'"></path></svg>',e.thumb.querySelector("path").style.transitionTimingFunction=t.value,this.domElement.append(e.wrapper)},bind:function(){this.domElement.on("vclick",".sl-easing-thumbnail",function(t){this.setValue(t.currentTarget.getAttribute("data-value"),!0)}.bind(this)),this.domElement.on("mouseover",".sl-easing-thumbnail",function(t){var e=t.currentTarget.querySelector("path"),i=e.getTotalLength(),n=this.config.thumbTransitionSeconds;"function"==typeof n&&(n=n()),e.style.transitionDuration=n+"s",e.setAttribute("stroke-dasharray",i),e.setAttribute("stroke-dashoffset",-i);var s=1;clearInterval(this.lineDrawingInterval),this.lineDrawingInterval=setInterval(function(){e.setAttribute("stroke-dashoffset",-i*++s)},1e3*n+200)}.bind(this)),this.domElement.on("mouseout",".sl-easing-thumbnail",function(t){var e=t.currentTarget.querySelector("path");e.removeAttribute("stroke-dasharray"),e.removeAttribute("stroke-dashoffset"),clearInterval(this.lineDrawingInterval)}.bind(this))},appendTo:function(t){this.domElement.appendTo(t)},focus:function(){var t=this.domElement.find(".sl-easing-thumbnail.selected");t||(t=this.domElement.find(".sl-easing-thumbnail").first()),t.focus()},selectFocusedElement:function(){var t=this.domElement.find(":focus").closest(".sl-easing-thumbnail");t.length&&this.setValue(t.attr("data-value"),!0)},setValue:function(t,e){this.getValue();this.domElement.find(".sl-easing-thumbnail.selected").removeClass("selected"),this.domElement.find('.sl-easing-thumbnail[data-value="'+t+'"]').addClass("selected"),e&&this.selectionChanged.dispatch(t)},getValue:function(){return this.domElement.find(".sl-easing-thumbnail.selected").attr("data-value")},getTitleForCurrentValue:function(){return this.domElement.find(".sl-easing-thumbnail.selected").attr("data-title")},destroy:function(){this.selectionChanged&&(this.selectionChanged.dispose(),this.selectionChanged=null),clearInterval(this.lineDrawingInterval),this.config=null,this.domElement.remove()}}),SL("components.form").Autocomplete=Class.extend({init:function(t,e,i){this.inputElement=t,this.searchMethod=e,this.confirmed=new signals.Signal,this.config=$.extend({offsetY:0,offsetX:0,className:null},i),this.render(),this.bind()},render:function(){this.domElement=$('<div class="sl-autocomplete">'),this.config.className&&this.domElement.addClass(this.config.className)},bind:function(){this.onDocumentKeydown=this.onDocumentKeydown.bind(this),this.showSuggestions=this.showSuggestions.bind(this),this.hideSuggestions=this.hideSuggestions.bind(this),this.layout=$.throttle(this.layout,500,this),this.onInput=$.throttle(this.onInput,500,this),this.inputElement.on("input",this.onInput),this.inputElement.on("focus",this.onInput),this.inputElement.on("blur",this.hideSuggestions),this.domElement.on("mousedown",this.onClick.bind(this))},layout:function(){var t=this.inputElement.get(0).getBoundingClientRect();this.domElement.css({top:t.bottom+this.config.offsetY,left:t.left+this.config.offsetX,width:t.width})},showSuggestions:function(t){var e=t.map(function(t,e){var i="sl-autocomplete-item"+(0===e?" focus":"");return"string"==typeof t&&(t={value:t,label:t}),'<div class="'+i+'" data-value="'+t.value+'">'+t.label+"</div>"});this.domElement.html(e.join("")),this.domElement.appendTo(document.body),this.layout(),$(window).on("resize",this.layout),SL.keyboard.keydown(this.onDocumentKeydown)},hideSuggestions:function(){this.domElement.detach(),$(window).off("resize",this.layout),SL.keyboard.release(this.onDocumentKeydown)},focus:function(t){var e=this.domElement.find(".focus");e.length||(e=this.domElement.find(".sl-autocomplete-item").first(),e.addClass("focus"));var i=t>0?e.next(".sl-autocomplete-item"):e.prev(".sl-autocomplete-item");i.length&&(e.removeClass("focus"),i.addClass("focus"))},setValue:function(t){this.inputElement.val(t),this.confirmed.dispatch(t)},getFocusedValue:function(){return this.domElement.find(".focus").attr("data-value")},destroy:function(){this.confirmed.dispose(),this.inputElement.off("input",this.onInput),this.hideSuggestions()},onInput:function(){this.searchMethod(this.inputElement.val()).then(function(t){t.length>0?this.inputElement.is(":focus")&&this.showSuggestions(t):this.hideSuggestions()}.bind(this),function(){this.hideSuggestions()}.bind(this))},onClick:function(t){var e=$(t.target).closest(".sl-autocomplete-item");e.length&&(this.setValue(e.attr("data-value")),this.hideSuggestions())},onDocumentKeydown:function(t){return 27===t.keyCode?(this.hideSuggestions(),!1):13===t.keyCode||9===t.keyCode?(this.setValue(this.getFocusedValue()),this.hideSuggestions(),!1):38===t.keyCode?(this.focus(-1),!1):40!==t.keyCode||(this.focus(1),!1)}}),SL("components.form").Scripts=Class.extend({init:function(t){this.domElement=$(t),this.render(),this.readValues(),this.renderList()},render:function(){this.valueElement=this.domElement.find(".value-holder"),this.listElement=$('<ul class="list">'),this.listElement.delegate("li .remove","click",this.onListItemRemove.bind(this)),this.listElement.appendTo(this.domElement),this.inputWrapper=$('<div class="input-wrapper"></div>').appendTo(this.domElement),this.inputElement=$('<input type="text" placeholder="https://...">'),this.inputElement.on("keyup",this.onInputKeyUp.bind(this)),this.inputElement.appendTo(this.inputWrapper),this.submitElement=$('<div class="button outline">Add</div>'),this.submitElement.on("click",this.submitInput.bind(this)),this.submitElement.appendTo(this.inputWrapper),this.domElement.parents("form").first().on("submit",this.onFormSubmit.bind(this))},renderList:function(){this.listElement.empty(),this.values.forEach(function(t){this.listElement.append(['<li class="list-item" data-value="'+t+'">',t,'<span class="icon i-x remove"></span>',"</li>"].join(""))}.bind(this))},formatValues:function(){for(var t=0;t<this.values.length;t++)this.values[t]=SL.util.string.trim(this.values[t]),""===this.values[t]&&this.values.splice(t,1)},readValues:function(){this.values=(this.valueElement.val()||"").split(","),this.formatValues()},writeValues:function(){this.formatValues(),this.valueElement.val(this.values.join(","))},addValue:function(t){return t=t||"",0===t.search(/https\:\/\//gi)?(this.values.push(t),this.renderList(),this.writeValues(),!0):0===t.search(/http\:\/\//gi)?(SL.notify("Script must be loaded via HTTPS","negative"),!1):(SL.notify("Please enter a valid script URL","negative"),!1)},removeValue:function(t){if("string"==typeof t)for(var e=0;e<this.values.length;e++)this.values[e]===t&&this.values.splice(e,1);else"number"==typeof t&&this.values.splice(t,1);this.renderList(),this.writeValues()},submitInput:function(){this.addValue(this.inputElement.val())&&this.inputElement.val("")},onListItemRemove:function(t){var e=$(t.target).parent().index();"number"==typeof e&&this.removeValue(e)},onInputKeyUp:function(t){13===t.keyCode&&this.submitInput()},onFormSubmit:function(t){if(this.inputElement.is(":focus"))return t.preventDefault(),!1}}),SL("components").FormUnit=Class.extend({init:function(t){this.domElement=$(t),this.inputElement=this.domElement.find("input, textarea").first(),this.errorElement=$('<div class="status error">'),this.errorIcon=$('<span class="icon">!</span>').appendTo(this.errorElement),this.errorMessage=$('<p class="message">!</p>').appendTo(this.errorElement),this.successText=this.domElement.attr("data-success-text"),this.successElement=$('<div class="status success">'),this.successIcon=$('<span class="icon i-checkmark"></span>').appendTo(this.successElement),this.successIcon.attr("data-tooltip",this.successText),this.validateType=this.domElement.attr("data-validate"),this.validateTimeout=-1,this.originalValue=this.inputElement.val(),this.originalError=this.domElement.attr("data-error-message"),this.asyncValidatedValue=null,this.clientErrors=[],this.serverErrors=[],this.inputElement.on("input",this.onInput.bind(this)),this.inputElement.on("change",this.onInputChange.bind(this)),this.inputElement.on("focus",this.onInputFocus.bind(this)),this.inputElement.on("blur",this.onInputBlur.bind(this)),this.inputElement.on("invalid",this.onInputInvalid.bind(this)),this.domElement.parents("form").first().on("submit",this.onFormSubmit.bind(this)),this.inputElement.hasClass("prevent-autocomplete")&&(this.onRemoveReadonly=this.onRemoveReadonly.bind(this),this.inputElement.on("mousedown touchstart focus hover",this.onRemoveReadonly)),this.originalError?(this.domElement.removeClass("hidden"),this.validate(),this.inputElement.focus()):this.render(),this.domElement.data("controller",this),this.domElement.hasClass("label-placeholder")&&this.monitorAutofill(),this.domElement.hasClass("image")&&this.bindImage()},validate:function(t){clearTimeout(this.validateTimeout);var e=this.inputElement.val();if("string"!=typeof e)return this.serverErrors=[],this.clientErrors=[],void this.render();if("checkbox"===this.inputElement.attr("type"))this.clientErrors=[],!this.inputElement.prop("checked")&&t&&this.isRequired()&&this.clientErrors.push(SL.locale.FORM_ERROR_REQUIRED);else if(e===this.originalValue&&(this.originalValue||"password"===this.validateType)&&this.originalError)this.clientErrors=[this.originalError];else if(e.length){var i=SL.util.validate[this.validateType];"function"==typeof i?this.clientErrors=i(e):console.log('Could not find validation method of type "'+this.validateType+'"')}else this.clientErrors=[],t&&this.isRequired()&&this.clientErrors.push(SL.locale.FORM_ERROR_REQUIRED);return this.validateAsync(),this.render(),0===this.clientErrors.length&&0===this.serverErrors.length},validateAsync:function(){if("username"===this.validateType){var t=SLConfig&&SLConfig.current_user?SLConfig.current_user.username:"",e=this.inputElement.val();0===SL.util.validate.username(e).length&&(t&&e===t?(this.asyncValidatedValue=t,this.serverErrors=[]):e!==this.asyncValidatedValue&&$.ajax({url:SL.endpoints.LOOKUP_USER,type:"GET",data:{id:e},context:this,statusCode:{204:function(){this.serverErrors=[SL.locale.get("FORM_ERROR_USERNAME_TAKEN")]},404:function(){this.serverErrors=[]}}}).complete(function(){this.render(),this.asyncValidatedValue=e}))}else if("team_slug"===this.validateType){var i=SL.current_team?SL.current_team.get("slug"):"",n=this.inputElement.val();0===SL.util.validate.team_slug(n).length&&(i&&n===i?(this.asyncValidatedValue=i,this.serverErrors=[]):n!==this.asyncValidatedValue&&$.ajax({url:SL.endpoints.LOOKUP_TEAM,type:"GET",data:{id:n},context:this,statusCode:{204:function(){this.serverErrors=[SL.locale.get("FORM_ERROR_ORGANIZATION_SLUG_TAKEN")]},404:function(){this.serverErrors=[]}}}).complete(function(){this.render(),this.asyncValidatedValue=n}))}},validateAfterTimeout:function(){if(clearTimeout(this.validateTimeout),!SL.util.device.IS_PHONE&&!SL.util.device.IS_TABLET){var t=600;(this.clientErrors.length||this.serverErrors.length)&&(t=300),this.validateTimeout=setTimeout(this.validate.bind(this),t)}},render:function(){var t=this.serverErrors.concat(this.clientErrors);this.domElement.toggleClass("has-error",t.length>0),t.length>0?(this.errorElement.appendTo(this.domElement),
this.errorMessage.text(t[0]),setTimeout(function(){this.errorElement.addClass("visible")}.bind(this),1)):this.errorElement.removeClass("visible").remove(),0===t.length&&!this.isEmpty()&&this.successText?(this.successElement.appendTo(this.domElement),setTimeout(function(){this.successElement.addClass("visible")}.bind(this),1)):this.successElement.removeClass("visible").remove()},format:function(){if("username"===this.validateType||"team_slug"===this.validateType){var t=this.inputElement.val();t&&this.inputElement.val(this.inputElement.val().toLowerCase())}if("url"===this.validateType){var t=this.inputElement.val();t&&t.length>2&&/^http(s?):\/\//gi.test(t)===!1&&this.inputElement.val("http://"+t)}},focus:function(){this.inputElement.focus()},beforeSubmit:function(){return this.validate(!0),!(this.clientErrors.length>0||this.serverErrors.length>0)||(this.focus(),!1)},bindImage:function(){this.domElement.find(".image-uploader-upload-button").on("click",function(t){t.preventDefault(),this.inputElement.click()}.bind(this)),this.domElement.find(".image-uploader-remove-button").on("click",function(t){t.preventDefault(),this.domElement.find(".image-uploader-preview").empty(),this.domElement.find(".image-uploader").attr("data-state","empty"),this.inputElement.get(0).value="";var e=this.domElement.find(".image-uploader").attr("data-image-type");"team-logo"===e?$.ajax({url:SL.endpoints.REMOVE_TEAM_LOGO,type:"DELETE",context:this}).fail(function(){SL.notify("An error occured while removing the image","negative")}):"profile-photo"===e&&$.ajax({url:SL.endpoints.REMOVE_USER_AVATAR,type:"DELETE",context:this}).done(function(t){$('<img src="'+t.thumbnail_url+'">').appendTo(this.domElement.find(".image-uploader-preview"))}).fail(function(){SL.notify("An error occured while removing the image","negative")})}.bind(this))},renderImage:function(){var t=this.inputElement.get(0);if(t.files&&t.files[0]){var e=new FileReader;e.addEventListener("load",function(t){var e=this.domElement.find("img"),i=t.target.result;this.domElement.find(".image-uploader").attr("data-state","populated"),e.length?e.attr("src",i):$('<img src="'+i+'">').appendTo(this.domElement.find(".image-uploader-preview"))}.bind(this)),e.readAsDataURL(t.files[0])}},monitorAutofill:function(){var t=setInterval(function(){try{this.inputElement.toggleClass("is-autofilled",this.inputElement.is(":-webkit-autofill"))}catch(e){clearInterval(t)}}.bind(this),250)},isEmpty:function(){return 0===this.inputElement.val().length},isRequired:function(){return!this.domElement.hasClass("hidden")&&this.domElement.is("[data-required]")},isUnchanged:function(){return this.inputElement.val()===this.originalValue},onInput:function(){this.validateAfterTimeout()},onInputChange:function(t){this.domElement.hasClass("image")&&this.renderImage(t.target),this.validate()},onInputFocus:function(){this.domElement.addClass("focused")},onInputBlur:function(){this.format(),this.domElement.removeClass("focused")},onInputInvalid:function(){return this.beforeSubmit()},onFormSubmit:function(t){if(this.beforeSubmit()===!1)return t.preventDefault(),!1},onRemoveReadonly:function(){this.inputElement.off("mousedown touchstart focus hover",this.onRemoveReadonly),this.inputElement.removeClass("prevent-autocomplete").removeAttr("readonly")}}),SL("components").Header=Class.extend({init:function(){this.domElement=$(".global-header"),this.navWrapperElement=this.domElement.find(".nav-wrapper"),this.navElement=this.domElement.find(".nav"),this.renderLogo(),this.renderDropdown(),this.checkScrollPosition(),this.checkOverflow(),this.bind()},renderLogo:function(){if("/"===window.location.pathname){var t=this.domElement.find(".logo-animation");t.length&&new SL.components.Menu({anchor:t,anchorSpacing:10,alignment:"b",showOnHover:!0,options:[{label:"Download logo",url:SL.routes.BRAND_KIT}]})}},renderDropdown:function(){this.dropdown=SL.components.Header.createMainMenu(this.domElement.find(".profile-button .nav-item-anchor"))},bind:function(){this.domElement.hasClass("show-on-scroll")&&$(document).on("mousemove",this.onDocumentMouseMove.bind(this)),$(window).on("scroll",this.checkScrollPosition.bind(this)),$(window).on("resize scroll",this.checkOverflow.bind(this)),this.domElement.find(".new-deck-button").on("vclick",this.onNewDeckClicked.bind(this))},checkScrollPosition:function(){var t=$(window).scrollTop();this.isScrolledDown=t>30,this.domElement.toggleClass("is-scrolled-30",t>30),this.domElement.toggleClass("is-scrolled-150",t>150),this.domElement.toggleClass("show",this.isScrolledDown)},checkOverflow:function(){this.navWrapperElement.prop("scrollHeight")>this.navWrapperElement.prop("offsetHeight")?(this.overflowMenuElement&&this.overflowMenuElement.prop("offsetTop")>0&&this.overflowMenuElement.insertAfter(this.overflowMenuElement.next(":not(.overflow-disabled)")),this.navElement.find(".nav-item:not(.overflow-disabled)").toArray().forEach(function(t){t.offsetTop>0?t.classList.add("overflowing"):t.classList.remove("overflowing")},this)):this.navElement.find(".nav-item").removeClass("overflowing"),this.refreshOverflowMenu()},refreshOverflowMenu:function(){var t=this.navElement.find(".nav-item.overflowing");if(t.length){this.overflowMenuElement||(this.overflowMenuElement=$('<li class="nav-item overflow-button overflow-disabled"><div class="nav-item-anchor"><span class="nav-item-label icon i-chevron-down" style="transform: scale(1.4)"></span></div></li>')),this.overflowMenuElement.insertAfter(t.last()),this.overflowMenuElement&&this.overflowMenuElement.prop("offsetTop")>0&&this.overflowMenuElement.insertAfter(this.overflowMenuElement.next(":not(.overflow-disabled)"));var e=t.toArray().map(function(t){return t.textContent.replace(/\s/g,"")}).join("");this.previousOverflowHash&&e===this.previousOverflowHash||(this.previousOverflowHash=e,this.overflowMenu&&this.overflowMenu.destroy(),this.overflowMenu=new SL.components.Menu({anchor:this.overflowMenuElement.find(".nav-item-anchor"),alignment:"auto",minWidth:160,showOnHover:!0,options:t.toArray().map(function(t){return{label:t.querySelector(".nav-item-label").textContent,url:t.querySelector("a").getAttribute("href")}})}))}else this.overflowMenuElement&&(this.overflowMenuElement.remove(),this.overflowMenuElement=null),this.overflowMenu&&(this.overflowMenu.destroy(),this.overflowMenu=null),this.previousOverflowHash=null},onDocumentMouseMove:function(t){if(!this.isScrolledDown){var e=t.clientY;e>0&&(e<20&&!this.isMouseOver?(this.domElement.addClass("show"),this.isMouseOver=!0):e>80&&this.isMouseOver&&0===$(t.target).parents(".global-header").length&&(this.domElement.removeClass("show"),this.isMouseOver=!1))}},onNewDeckClicked:function(t){!SL.current_user.privileges.deckTemplateSelector()||t.metaKey||t.ctrlKey||t.shiftKey||(SL.popup.openOne(SL.components.popup.DeckTemplates),t.preventDefault())}}),SL.components.Header.createMainMenu=function(t){var e=[{label:"Profile",icon:"home",url:SL.routes.USER(SL.current_user.get("username"))},{label:"New deck",icon:"plus",callback:function(t){!SL.current_user.privileges.deckTemplateSelector()||t.metaKey||t.ctrlKey||t.shiftKey||(SL.popup.openOne(SL.components.popup.DeckTemplates),t.preventDefault())},url:SL.routes.DECK_NEW(SL.current_user.get("username"))}];if(SL.current_user.isEnterpriseManager()){e.push({label:"Themes",icon:"brush",url:SL.routes.THEME_EDITOR});var i={label:"Settings",icon:"cog",url:SL.routes.USER_EDIT};SL.current_team&&(i.submenu=[{label:"Account settings",url:SL.routes.USER_EDIT,className:"account-settings-button"},{label:"Team settings",url:SL.routes.TEAM_EDIT(SL.current_team)},{label:"Team members",url:SL.routes.TEAM_EDIT_MEMBERS(SL.current_team)}],SL.current_team.isManuallyUpgraded()||i.submenu.push({label:"Billing details",url:SL.routes.BILLING_DETAILS})),e.push(i)}else e.push({label:"Settings",icon:"cog",url:SL.routes.USER_EDIT,className:"account-settings-button"});SL.current_user.isManuallyUpgraded()||SL.current_user.isEnterprise()||(SL.current_user.isPaid()?e.push({label:"Billing",icon:"credit",url:SL.routes.BILLING_DETAILS,className:"billing-details-button"}):e.push({label:"Upgrade",icon:"star",url:SL.routes.PRICING}));var n=$(".global-header .nav-item-changelog");return n.length&&(e.push({label:"What's new",url:SL.routes.CHANGELOG,iconHTML:'<span class="counter"><span class="counter-inner">'+n.attr("data-unread-count")+"</span></span>"}),t.find(".nav-item-burger").append('<span class="changelog-indicator"></span>'),t.one("mouseover",function(){$(this).find(".changelog-indicator").remove()})),e.push({label:"Log out",icon:"exit",url:SL.routes.SIGN_OUT,className:"logout-button",attributes:{rel:"nofollow","data-method":"delete"}}),new SL.components.Menu({anchor:t,anchorSpacing:10,alignment:"auto",minWidth:160,showOnHover:!0,options:e})},SL("components").Kudos=function(){function t(){$("[data-kudos-value][data-kudos-id]").each(function(t,e){var i=e.getAttribute("data-kudos-id");i&&!a[i]&&(a[i]=e.getAttribute("data-kudos-value"))}.bind(this)),$(".kudos-trigger[data-kudos-id]").on("vclick",function(t){var n=t.currentTarget;"true"===n.getAttribute("data-kudoed-by-user")?i(n.getAttribute("data-kudos-id")):e(n.getAttribute("data-kudos-id"))}.bind(this))}function e(t){n(t),$.ajax({type:"POST",url:SL.endpoints.KUDO_DECK(t),context:this}).fail(function(){s(t),SL.notify(SL.locale.get("GENERIC_ERROR"))})}function i(t){s(t),$.ajax({type:"DELETE",url:SL.endpoints.UNKUDO_DECK(t),context:this}).fail(function(){n(t),SL.notify(SL.locale.get("GENERIC_ERROR"))})}function n(t){var e=$('.kudos-trigger[data-kudos-id="'+t+'"]');e.attr("data-kudoed-by-user","true"),a[t]++,o(t,a[t]);var i=e.find(".kudos-icon");i.length&&(i.removeClass("bounce"),setTimeout(function(){i.addClass("bounce")},1))}function s(t){var e=$('.kudos-trigger[data-kudos-id="'+t+'"]');e.attr("data-kudoed-by-user","false"),a[t]--,o(t,a[t]),e.find(".kudos-icon").removeClass("bounce")}function o(t,e){"number"==typeof a[t]&&("number"==typeof e&&(a[t]=e),e=Math.max(a[t],0),$("[data-kudos-id][data-kudos-value]").each(function(t,i){i.setAttribute("data-kudos-value",e)}))}var a={};t()}(),SL("components.medialibrary").Filters=Class.extend({init:function(t,e,i){this.options=$.extend({editable:!0,searchPlaceholder:"Search..."},i),this.media=t,this.media.changed.add(this.onMediaChanged.bind(this)),this.tags=e,this.tags.changed.add(this.onTagsChanged.bind(this)),this.tags.associationChanged.add(this.onTagAssociationChanged.bind(this)),this.filterChanged=new signals.Signal,this.onSearchInput=$.throttle(this.onSearchInput,300),this.render(),this.recount(),this.selectDefaultFilter(!0)},render:function(){this.domElement=$('<div class="media-library-filters">'),this.domElement.toggleClass("editable",this.options.editable),this.innerElement=$('<div class="media-library-filters-inner">').appendTo(this.domElement),this.scrollElement=this.innerElement,this.renderSearch(),this.renderTypes(),this.renderTags()},renderTypes:function(){this.renderType(SL.models.Media.ALL.id,SL.models.Media.ALL.filter,"All");var t=$('<div class="media-library-filter-types">').appendTo(this.innerElement),e=this.renderType(SL.models.Media.IMAGE.id,SL.models.Media.IMAGE.filter,"Images","All Images","i-picture");e.addClass("media-type"),e.appendTo(t);var i=this.renderType(SL.models.Media.VIDEO.id,SL.models.Media.VIDEO.filter,"Videos","All Videos","i-video-camera");if(i.addClass("media-type"),i.appendTo(t),this.options.editable){var n=this.renderType(SL.models.Media.TRASHED.id,SL.models.Media.TRASHED.filter,"Trash","Trash","i-trash");n.addClass("media-type"),n.appendTo(t)}},renderType:function(t,e,i,n,s){var o=$(['<div class="media-library-filter media-library-type-filter">','<span class="label">'+i+"</span>",'<span class="count"></span>',"</div>"].join("")),a={"data-id":t,"data-label":i,"data-exclusive-label":n};return"string"==typeof s&&(a["data-icon"]=s,o.attr("data-tooltip",i)),o.attr(a),o.on("vclick",this.onFilterClicked.bind(this)),o.data("filter",e),o.appendTo(this.innerElement),o},renderTags:function(){this.tagsElement=$(['<div class="media-library-tags media-drop-area">','<div class="tags-list"></div>',"</div>"].join("")),this.tagsElement.appendTo(this.innerElement),this.tagsList=this.tagsElement.find(".tags-list"),this.options.editable&&(this.tagsElement.append(['<div class="tags-create">','<div class="tags-create-inner ladda-button" data-style="expand-right" data-spinner-color="#666" data-spinner-size="28">New tag</div>',"</div>"].join("")),this.tagsElement.find(".tags-create").on("vclick",this.onCreateTagClicked.bind(this)),this.tagsCreateLoader=Ladda.create(this.tagsElement.find(".tags-create-inner").get(0))),this.tags.forEach(this.renderTag.bind(this)),this.sortTags()},renderTag:function(t){var e=$(['<div class="media-library-filter media-drop-target" data-id="'+t.get("id")+'">','<div class="front">','<span class="label-output"></span>','<div class="controls-out">','<span class="count"></span>',"</div>","</div>","</div>","</div>"].join(""));return e.find(".label-output").text(t.get("name")),e.on("vclick",this.onTagClicked.bind(this)),e.data({model:t,filter:t.createFilter()}),this.options.editable?(e.find(".front").append(['<div class="controls-over">','<span class="controls-button edit-button">Edit</span>',"</div>"].join("")),e.append(['<div class="back">','<input class="label-input" value="" type="text">','<div class="controls">','<span class="controls-button delete-button negative icon i-trash"></span>','<span class="controls-button save-button">Save</span>',"</div>","</div>"].join("")),e.find(".label-input").val(t.get("name")),e.data("dropReceiver",function(e){this.tags.addTagTo(t,e)}.bind(this))):e.find(".controls-out").removeClass("controls-out").addClass("controls-permanent"),e.appendTo(this.tagsList),e},renderSearch:function(){this.searchElement=$(['<div class="media-library-filter media-library-search-filter" data-id="search">','<input class="search-input" type="text" placeholder="'+this.options.searchPlaceholder+'" maxlength="50" />',"</div>"].join("")),this.searchElement.on("vclick",this.onSearchClicked.bind(this)),this.searchElement.data("filter",function(){return!1}),this.searchElement.appendTo(this.innerElement),this.searchInput=this.searchElement.find(".search-input"),this.searchInput.on("input",this.onSearchInput.bind(this))},recount:function(t){t=t||this.domElement.find(".media-library-filter"),t.each(function(t,e){var i=$(e),n=i.find(".count");if(n.length){var s=0;s=this.typeFilter?this.media.filter(i.data("filter")).filter(this.typeFilter).length:this.media.filter(i.data("filter")).length,i.data("id")===SL.models.Media.TRASHED.id&&i.toggleClass("hidden",0===s),n.text(s)}}.bind(this))},appendTo:function(t){this.domElement.appendTo(t)},selectFilter:function(t,e){var i=this.domElement.find('.media-library-filter[data-id="'+t+'"]');this.domElement.find(".is-selected").removeClass("is-selected"),i.addClass("is-selected"),this.selectedFilter=i.data("filter"),this.selectedFilterData={},i.closest(this.tagsList).length?(this.selectedFilterData.type=SL.components.medialibrary.Filters.FILTER_TYPE_TAG,this.selectedFilterData.tag=i.data("model"),this.selectedFilterData.placeholder="No media has been added to this tag",this.options.editable&&(this.selectedFilterData.placeholder="This tag is empty. To add media, drag and drop it onto the tag in the sidebar.")):(this.selectedFilterData.type=SL.components.medialibrary.Filters.FILTER_TYPE_MEDIA,this.selectedFilterData.placeholder="There is no media of this type"),e||this.filterChanged.dispatch(this.selectedFilter,this.selectedFilterData)},selectDefaultFilter:function(t){this.selectFilter(this.domElement.find(".media-library-filter:not(.media-library-search-filter)").first().attr("data-id"),t)},showAllTypes:function(){this.domElement.find(".media-library-type-filter").each(function(){var t=$(this);t.css("display","");var e=t.attr("data-icon");"string"==typeof e?t.find(".label").html('<span class="icon '+e+'"></span>'):t.find(".label").text(t.attr("data-label"))}),this.typeFilter=null,this.recount()},hideAllTypesExcept:function(t,e){this.domElement.find(".media-library-type-filter").each(function(){var e=$(this);if(e.attr("data-id")===t)e.css("display",""),e.find(".label").text(e.attr("data-exclusive-label"));else{e.css("display","none");var i=e.attr("data-icon");"string"==typeof i?e.find(".label").html('<span class="icon '+i+'"></span>'):e.find(".label").text(e.attr("data-label"))}}),this.typeFilter=e,this.recount()},startEditingTag:function(t,e){if(this.tagsList.find(".is-editing").length)return!1;var i=(t.data("model"),t.find(".label-input"));this.domElement.addClass("is-editing"),e===!0&&(t.find(".label-output").empty(),t.addClass("no-transition"),setTimeout(function(){t.removeClass("no-transition")},1),this.scrollElement.animate({scrollTop:t.prop("offsetTop")+80-this.scrollElement.height()},300)),t.addClass("is-editing");var n=this.scrollElement.prop("scrollTop");i.focus().select(),this.scrollElement.prop("scrollTop",n),i.on("keydown",function(e){13===e.keyCode&&(e.preventDefault(),this.stopEditingTag(t))}.bind(this))},stopEditingTag:function(t,e){var i=t.data("model"),n=t.find(".label-input"),s=t.find(".label-output");this.domElement.removeClass("is-editing");var o=n.val();o&&!e&&(i.set("name",o),i.save(["name"])),s.text(i.get("name")),n.off("keydown"),setTimeout(function(){t.removeClass("is-editing")},1)},sortTags:function(){var t=this.tagsList.find(".media-library-filter").toArray();t.sort(function(t,e){return t=$(t).data("model").get("name").toLowerCase(),e=$(e).data("model").get("name").toLowerCase(),t<e?-1:t>e?1:0}),t.forEach(function(t){$(t).appendTo(this.tagsList)}.bind(this))},getTagElementByID:function(t){return this.tagsList.find('.media-library-filter[data-id="'+t+'"]')},confirmTagRemoval:function(t){var e=t.data("model");SL.prompt({anchor:t.find(".delete-button"),title:SL.locale.get("TAG_DELETE_CONFIRM"),type:"select",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Delete</h3>",selected:!0,className:"negative",callback:function(){SL.analytics.trackEditor("Media: Delete tag"),e.destroy().done(function(){this.domElement.removeClass("is-editing"),this.tags.remove(e),SL.notify(SL.locale.get("TAG_DELETE_SUCCESS"))}.bind(this)).fail(function(){SL.notify(SL.locale.get("TAG_DELETE_ERROR"),"negative")}.bind(this))}.bind(this)}]})},getSelectedFilterData:function(){return this.selectedFilterData},destroy:function(){this.filterChanged.dispose(),this.domElement.remove()},onMediaChanged:function(){this.recount()},onTagsChanged:function(t,e){t&&t.length&&t.forEach(function(t){this.startEditingTag(this.renderTag(t),!0)}.bind(this)),e&&e.length&&e.forEach(function(t){var e=this.tagsElement.find('[data-id="'+t.get("id")+'"]');this.stopEditingTag(e,!0),e.remove(),e.hasClass("is-selected")&&this.selectDefaultFilter()}.bind(this))},onTagAssociationChanged:function(t){this.recount(this.getTagElementByID(t.get("id")))},onFilterClicked:function(t){this.selectFilter($(t.currentTarget).attr("data-id"))},onCreateTagClicked:function(){this.tagsCreateLoader.start(),this.tags.create().then(function(t){this.recount(this.getTagElementByID(t.get("id"))),this.tagsCreateLoader.stop()}.bind(this),function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative"),this.tagsCreateLoader.stop()}.bind(this)),SL.analytics.trackEditor("Media: Create tag")},onTagClicked:function(t){var e=$(t.target),i=e.closest(".media-library-filter");i.length&&(e.closest(".edit-button").length?this.startEditingTag(i):e.closest(".save-button").length?this.stopEditingTag(i):e.closest(".delete-button").length?this.confirmTagRemoval(i):i.hasClass("is-editing")||this.onFilterClicked(t))},onSearchClicked:function(){this.selectFilter(this.searchElement.attr("data-id"),!0),this.searchInput.focus(),this.onSearchInput(),SL.analytics.trackEditor("Media: Search clicked")},onSearchInput:function(){var t=this.searchInput.val();this.selectedFilter=this.media.createSearchFilter(t),this.selectedFilterData={type:SL.components.medialibrary.Filters.FILTER_TYPE_SEARCH,placeholder:"Please enter a search term"},this.searchElement.data("filter",this.selectedFilter),t.length>0&&(this.selectedFilterData.placeholder='No results for "'+t+'"'),this.filterChanged.dispatch(this.selectedFilter,this.selectedFilterData)}}),SL.components.medialibrary.Filters.FILTER_TYPE_MEDIA="media",SL.components.medialibrary.Filters.FILTER_TYPE_TAG="tag",SL.components.medialibrary.Filters.FILTER_TYPE_SEARCH="search",SL("components.medialibrary").ListDrag=Class.extend({init:function(){this.items=[],this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this)},reset:function(){$("html").removeClass("dragging-media"),this.items=[],this.ghostElement&&this.ghostElement.remove(),this.currentDropTarget=null,$(".media-drop-target").removeClass("drag-over"),$(document).off("vmousemove",this.onMouseMove),$(document).off("vmouseup",this.onMouseUp)},startDrag:function(t,e,i){$("html").addClass("dragging-media"),this.items=i;var n=e[0];this.ghostWidth=n.width()/2,this.ghostHeight=n.height()/2,this.ghostElement=$('<div class="media-library-drag-ghosts">').appendTo(document.body),this.ghostElement.css("max-width",6*this.ghostWidth),e.slice(0,10).forEach(function(t){t=$(t),$('<div class="media-library-drag-ghost">').css({backgroundImage:t.css("background-image"),backgroundSize:t.css("background-size"),backgroundPosition:t.css("background-position"),width:this.ghostWidth,height:this.ghostHeight}).appendTo(this.ghostElement)},this),this.items.length>10&&this.ghostElement.find(".media-library-drag-ghost").last().append('<span class="count">+'+(this.items.length-10)+"</span>"),this.dropTargets=$(".media-drop-target"),$(document).on("vmousemove",this.onMouseMove),$(document).on("vmouseup",this.onMouseUp)},stopDrag:function(){this.reset()},animateGhostsIntoTag:function(t){var e=this.ghostElement,i=t.offset();i.left+=t.width()/2,i.top+=t.height()/2,e.find(".media-library-drag-ghost").each(function(t,e){e=$(e);var n=e.offset(),s=i.left-n.left,o=i.top-n.top;e.css({transform:"translate("+s+"px,"+o+"px) scale(0.4)",transition:"all 0.4s cubic-bezier(0.860, 0.000, 0.070, 1.000)","transition-delay":t/30+"s",opacity:0})}),setTimeout(function(){e.remove()},1e3)},onMouseMove:function(t){t.preventDefault();var e=t.clientX,i=t.clientY,n="translate("+e+"px,"+i+"px)";this.ghostElement.css({webkitTransform:n,transform:n}),this.currentDropTarget=null,this.dropTargets.each(function(t,n){var s=$(n),o=n.getBoundingClientRect();e>o.left&&e<o.right&&i>o.top&&i<o.bottom?(s.addClass("drag-over"),this.currentDropTarget=s):s.removeClass("drag-over")}.bind(this))},onMouseUp:function(t){t.preventDefault(),this.currentDropTarget&&(this.currentDropTarget.data("dropReceiver").call(null,this.items),SL.analytics.trackEditor("Media: Drop items on tag"),this.animateGhostsIntoTag(this.currentDropTarget),this.ghostElement=null),this.stopDrag()}}),SL("components.medialibrary").List=Class.extend({init:function(t,e,i){this.options=$.extend({editable:!0},i),this.media=t,this.media.changed.add(this.onMediaChanged.bind(this)),this.tags=e,this.tags.associationChanged.add(this.onTagAssociationChanged.bind(this)),this.items=[],this.filteredItems=[],this.selectedItems=new SL.collections.Collection,this.overlayPool=[],this.itemSelected=new signals.Signal,this.drag=new SL.components.medialibrary.ListDrag,this.render(),this.bind()},render:function(){this.domElement=$('<div class="media-library-list">'),this.trayElement=$(['<div class="media-library-tray">','<div class="status"></div>','<button class="button negative hard-delete-button">Delete</button>','<button class="button outline white restore-button">Restore</button>','<button class="button negative soft-delete-button">Delete</button>','<button class="button outline white untag-button">Remove tag</button>','<button class="button outline white clear-button">Clear selection</button>',"</div>"].join("")),this.placeholderElement=$(['<div class="media-library-list-placeholder">',"Empty","</div>"].join("")),this.media.forEach(this.addItem.bind(this)),this.filteredItems=this.items},bind:function(){if(this.loadItemsInView=$.throttle(this.loadItemsInView,300),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.domElement.on("scroll",this.onListScrolled.bind(this)),this.trayElement.find(".hard-delete-button").on("vclick",this.onHardDeleteSelectionClicked.bind(this)),this.trayElement.find(".soft-delete-button").on("vclick",this.onSoftDeleteSelectionClicked.bind(this)),this.trayElement.find(".restore-button").on("vclick",this.onRestoreSelectionClicked.bind(this)),this.trayElement.find(".untag-button").on("vclick",this.onUntagSelectionClicked.bind(this)),this.trayElement.find(".clear-button").on("vclick",this.onClearSelectionClicked.bind(this)),SL.util.device.IS_PHONE||SL.util.device.IS_TABLET){var t=new Hammer(this.domElement.get(0));t.on("tap",this.onMouseUp),t.on("press",function(t){var e=$(t.target).closest(".media-library-list-item").data("item");e&&(this.lastSelectedItem=e,this.toggleSelection(e)),t.preventDefault()}.bind(this))}else this.domElement.on("vmousedown",this.onMouseDown.bind(this))},layout:function(){var t=$(".media-library-list-item").first();this.cellWidth=t.outerWidth(!0),this.cellHeight=t.outerHeight(!0),this.columnCount=Math.floor(this.domElement.outerWidth()/this.cellWidth)},appendTo:function(t){this.domElement.appendTo(t),this.trayElement.appendTo(t),this.placeholderElement.appendTo(t),this.layout(),this.loadItemsInView()},addItem:function(t,e,i){var n=$('<div class="media-library-list-item"></div>'),s={model:t,element:n,elementNode:n.get(0),selected:!1,visible:!0};n.data("item",s),e===!0?(n.prependTo(this.domElement),this.items.unshift(s)):(n.appendTo(this.domElement),this.items.push(s)),i===!0&&(n.addClass("has-intro hidden"),setTimeout(function(){n.removeClass("hidden")},1))},removeItem:function(t){for(var e=this.items.length;--e>=0;){var i=this.items[e];i.model===t&&(this.detachOverlay(i),i.model=null,i.element.remove(),this.items.splice(e,1))}},setPrimaryFilter:function(t){this.filterA=t,this.applyFilter()},clearPrimaryFilter:function(){this.filterA=null,this.applyFilter()},setSecondaryFilter:function(t,e){this.clearSelection(),this.filterB=t,this.filterBData=e,this.applyFilter(),this.setPlaceholderContent(e.placeholder),this.afterSelectionChange()},clearSecondaryFilter:function(){this.filterB=null,this.filterBData=null,this.applyFilter(),this.setPlaceholderContent("Empty")},applyFilter:function(){this.filteredItems=[];for(var t=0,e=this.items.length;t<e;t++){var i=this.items[t];this.filterA&&!this.filterA(i.model)||this.filterB&&!this.filterB(i.model)?(i.elementNode.style.display="none",i.visible=!1,this.detachOverlay(i)):(this.filteredItems.push(i),i.visible=!0,i.elementNode.style.display="")}this.domElement.scrollTop(0),this.loadItemsInView(),this.placeholderElement.toggleClass("visible",0===this.filteredItems.length)},loadItemsInView:function(){if(SL.tooltip.isVisible()&&SL.tooltip.hide(),this.filteredItems.length)for(var t,e,i=this.domElement.scrollTop(),n=100,s=this.domElement.outerHeight(),o=0,a=this.filteredItems.length;o<a;o++)t=this.filteredItems[o],e=Math.floor(o/this.columnCount)*this.cellHeight,e+this.cellHeight-i>-n&&e-i<s+n?(t.overlay||this.attachOverlay(t),this.loadThumbnail(t)):t.overlay&&!t.selected&&this.detachOverlay(t)},setPlaceholderContent:function(t){this.media.isEmpty()?this.options.editable?this.placeholderElement.html("You haven't uploaded any media yet.<br>Use the upload button to the left or drag media from your desktop."):this.placeholderElement.html("No media has been uploaded yet."):this.placeholderElement.html(t||"Empty")},loadThumbnail:function(t,e){if(t&&t.model){var i=t.model.get("thumb_url")+(e?"?"+Date.now():"");t.elementNode.hasAttribute("data-thumb-loaded")?e&&(t.elementNode.style.backgroundImage='url("'+i+'")'):(t.elementNode.style.backgroundImage='url("'+i+'")',t.elementNode.setAttribute("data-thumb-loaded","true"))}},attachOverlay:function(t){return!(t.overlay||!this.options.editable)&&(0===this.overlayPool.length&&this.overlayPool.push($(['<div class="info-overlay">','<span class="info-overlay-action inline-button icon i-embed" data-tooltip="Insert SVG inline"></span>','<span class="info-overlay-action preview-button icon i-eye" data-tooltip="Preview"></span>','<span class="info-overlay-action label-button icon i-type" data-tooltip="Rename"></span>','<span class="info-overlay-action select-button" data-tooltip="Select">','<span class="icon i-checkmark checkmark"></span>',"</span>","</div>"].join(""))),t.overlay=this.overlayPool.pop(),t.overlay.appendTo(t.element),t.model&&t.model.processingCompleted&&t.model.isProcessing()&&(t.model.processingCompleted.add(this.onProcessingSuccess.bind(this,t)),t.model.processingFailed.add(this.onProcessingFailed.bind(this,t)),t.elementNode.classList.add("is-processing")),void this.refreshOverlay(t))},refreshOverlay:function(t){if(t.overlay&&t.model){var e=t.model.get("label");e&&""!==e||(e="Label"),t.overlay.attr("data-tooltip",e),t.element.attr("data-state",t.model.isTrashed()?"trashed":""),t.model.isSVG()?(t.overlay.addClass("has-inline-option"),t.overlay.find(".inline-button").toggleClass("is-on",!!t.model.get("inline"))):t.overlay.removeClass("has-inline-option"),t.model.has("type")&&t.element.attr("data-type",t.model.get("type").toLowerCase())}},detachOverlay:function(t){t&&t.overlay&&(this.overlayPool.push(t.overlay),t.overlay=null),t&&t.model&&t.model.processingCompleted&&(t.model.processingCompleted.remove(this.onProcessingSuccess,this),t.model.processingFailed.remove(this.onProcessingFailed,this))},toggleSelection:function(t,e){t.visible&&(t.selected="boolean"==typeof e?e:!t.selected,t.selected?(t.element.addClass("is-selected"),this.selectedItems.pushUnique(t)):(t.element.removeClass("is-selected"),this.selectedItems.remove(t)),this.afterSelectionChange())},toggleSelectionThrough:function(t){if(this.lastSelectedItem){var e=!t.selected,i=this.lastSelectedItem.element.index(),n=t.element.index();if(n>i)for(var s=i+1;s<=n;s++)this.toggleSelection(this.items[s],e);else if(n<i)for(var s=n;s<i;s++)this.toggleSelection(this.items[s],e)}},clearSelection:function(){this.selectedItems.forEach(function(t){t.selected=!1,t.element.removeClass("is-selected")}.bind(this)),this.selectedItems.clear(),this.lastSelectedItem=null,this.afterSelectionChange()},afterSelectionChange:function(){var t=this.selectedItems.size(),e=this.selectedItems.some(function(t){return t.model.isTrashed()});this.domElement.toggleClass("is-selecting",t>0),this.trayElement.attr("data-state",e?"trashed":""),this.trayElement.toggleClass("visible",t>0),this.trayElement.find(".status").text(t+" "+SL.util.string.pluralize("item","s",1!==t)+" selected"),this.filterBData&&this.filterBData.type===SL.components.medialibrary.Filters.FILTER_TYPE_TAG?this.trayElement.find(".untag-button").show():this.trayElement.find(".untag-button").hide()},softDeleteSelection:function(){var t="Do you want to permanently delete this media from all existing presentations or remove it from the library?";this.selectedItems.size()>1&&(t="Do you want to permanently delete these items from all existing presentations or remove them from the library?"),SL.prompt({anchor:this.trayElement.find(".soft-delete-button"),title:t,type:"select",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Remove from library</h3>",callback:function(){this.selectedItems.forEach(function(t){t.model.set("hidden",!0),t.model.save(["hidden"]).fail(function(){SL.notify("An error occurred, media was not removed","negative")}.bind(this)),this.media.changed.dispatch()}.bind(this)),SL.notify("Moved "+this.selectedItems.size()+" "+SL.util.string.pluralize("item","s",this.selectedItems.size()>1)+" to trash"),this.clearSelection()}.bind(this)},{html:"<h3>Delete permanently</h3>",selected:!0,className:"negative",callback:function(){var t=this.selectedItems.map(function(t){var e=t.model;return this.media.remove(e),e.destroy().fail(function(){SL.notify("An error occurred, media was not deleted","negative")}.bind(this))}.bind(this));Promise.all(t).then(function(){SL.current_user.updateStorageUsed()}),this.clearSelection()}.bind(this)}]}),SL.analytics.trackEditor("Media: Delete items")},hardDeleteSelection:function(){SL.prompt({anchor:this.trayElement.find(".hard-delete-button"),title:"Do you want to permanently delete the selected items? They'll stop working in any presentation that uses them.",type:"select",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Delete permanently</h3>",selected:!0,className:"negative",callback:function(){var t=this.selectedItems.map(function(t){var e=t.model;return this.media.remove(e),e.destroy().fail(function(){SL.notify("An error occurred, media was not deleted","negative");
}.bind(this))}.bind(this));Promise.all(t).then(function(){SL.current_user.updateStorageUsed()}),this.clearSelection()}.bind(this)}]}),SL.analytics.trackEditor("Media: Delete items")},restoreSelection:function(){this.selectedItems.forEach(function(t){t.model.set("hidden",!1),t.model.save(["hidden"]).fail(function(){SL.notify("An error occurred, media was not restored","negative")}.bind(this)),this.media.changed.dispatch()}.bind(this)),SL.notify("Restored "+this.selectedItems.size()+" "+SL.util.string.pluralize("item","s",this.selectedItems.size()>1)),this.clearSelection()},editLabel:function(t){t.element.addClass("hover");var e=SL.prompt({anchor:t.element.find(".label-button"),title:"Rename",type:"input",confirmLabel:"Save",data:{value:t.model.get("label"),placeholder:"Label...",maxlength:SL.config.MEDIA_LABEL_MAXLENGTH,width:400}});e.confirmed.add(function(e){t.element.removeClass("hover"),e&&""!==e.trim()?(t.model.set("label",e),t.model.save(["label"]),this.refreshOverlay(t)):SL.notify("Label can't be empty","negative")}.bind(this)),e.canceled.add(function(){t.element.removeClass("hover")}.bind(this)),SL.analytics.trackEditor("Media: Edit item label")},toggleInline:function(t){t.model.set("inline",!t.model.get("inline")),t.model.save(["inline"]),this.refreshOverlay(t),SL.analytics.trackEditor("Media: Toggle inline SVG")},previewItem:function(t){SL.popup.openOne(SL.components.popup.PreviewMedia,{skipIntro:!0,titleItem:t.model.get("label"),mediaType:t.model.get("type").toLowerCase(),mediaURL:t.model.get("url")}),SL.analytics.trackEditor("Media: Preview media item")},onMediaChanged:function(t,e){t&&t.length&&t.forEach(function(t){this.addItem(t,!0,!0)}.bind(this)),e&&e.length&&e.forEach(this.removeItem.bind(this)),this.applyFilter()},onTagAssociationChanged:function(t){var e=this.filterBData&&this.filterBData.type===SL.components.medialibrary.Filters.FILTER_TYPE_TAG&&this.filterBData.tag.get("id")===t.get("id");e&&this.applyFilter()},onMouseDown:function(t){2!==t.button&&(this.mouseDownTarget=$(t.target),this.mouseDownX=t.clientX,this.mouseDownY=t.clientY,this.domElement.on("vmousemove",this.onMouseMove),this.domElement.on("vmouseup",this.onMouseUp))},onMouseMove:function(t){var e=SL.util.trig.distanceBetween({x:this.mouseDownX,y:this.mouseDownY},{x:t.clientX,y:t.clientY});if(e>10&&this.options.editable){var i=this.mouseDownTarget.closest(".media-library-list-item").data("item");if(i){this.domElement.off("vmousemove",this.onMouseMove),this.domElement.off("vmouseup",this.onMouseUp);var n=[i.element],s=[i.model];this.selectedItems.size()>0&&i.selected&&(n=this.selectedItems.map(function(t){return t.element}),s=this.selectedItems.map(function(t){return t.model})),this.drag.startDrag(t,n,s),SL.analytics.trackEditor("Media: Start drag",s.length>1?"multiple":"single")}}t.preventDefault()},onMouseUp:function(t){var e=$(t.target),i=e.closest(".media-library-list-item").data("item");i&&(this.selectedItems.size()>0||e.closest(".select-button").length?t.shiftKey?this.toggleSelectionThrough(i):(this.lastSelectedItem=i,this.toggleSelection(i)):t.shiftKey||t.metaKey?(this.lastSelectedItem=i,this.toggleSelection(i)):e.closest(".preview-button").length?this.previewItem(i):e.closest(".label-button").length?this.editLabel(i):e.closest(".inline-button").length?this.toggleInline(i):i.model.isTrashed()?this.toggleSelection(i):this.itemSelected.dispatch(i.model)),this.domElement.off("vmousemove",this.onMouseMove),this.domElement.off("vmouseup",this.onMouseUp),t.preventDefault()},onListScrolled:function(){this.loadItemsInView()},onSoftDeleteSelectionClicked:function(){this.softDeleteSelection()},onHardDeleteSelectionClicked:function(){this.hardDeleteSelection()},onRestoreSelectionClicked:function(){this.restoreSelection()},onUntagSelectionClicked:function(){if(this.filterBData&&this.filterBData.type===SL.components.medialibrary.Filters.FILTER_TYPE_TAG){var t=this.selectedItems.map(function(t){return t.model});this.tags.removeTagFrom(this.filterBData.tag,t),this.applyFilter(),this.clearSelection()}},onClearSelectionClicked:function(){this.clearSelection()},onProcessingSuccess:function(t){this.loadThumbnail(t,!0),t.elementNode.classList.remove("is-processing")},onProcessingFailed:function(t){t.elementNode.classList.remove("is-processing"),this.removeItem(t.model)}}),SL("components.medialibrary").MediaLibraryPage=Class.extend({init:function(t,e,i){this.media=t,this.media.loadCompleted.add(this.onMediaLoaded.bind(this)),this.media.loadFailed.add(this.onMediaFailed.bind(this)),this.tags=e,this.tags.loadCompleted.add(this.onTagsLoaded.bind(this)),this.tags.loadFailed.add(this.onTagsFailed.bind(this)),this.tags.changed.add(this.onTagsChanged.bind(this)),this.options=$.extend({editable:!0,selectAfterUpload:!0,enforceStorageLimit:!1,canUploadVideo:!0},i),this.selected=new signals.Signal,this.render(),this.setupDragAndDrop()},load:function(){this.mediaLoaded=!1,this.tagsLoaded=!1,this.loadStatus&&this.loadStatus.remove(),this.loadStatus=$('<div class="media-library-load-status">').appendTo(this.domElement),this.loadStatus.html("Loading..."),this.media.load(),this.tags.load()},onMediaLoaded:function(){this.mediaLoaded=!0,this.tagsLoaded&&this.onMediaAndTagsLoaded()},onMediaFailed:function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative"),this.loadStatus.html('Failed to load media <button class="button outline retry">Try again</button>'),this.loadStatus.find(".retry").on("click",this.load.bind(this))},onTagsLoaded:function(){this.tagsLoaded=!0,this.mediaLoaded&&this.onMediaAndTagsLoaded()},onTagsFailed:function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative"),this.loadStatus.html('Failed to load tags <button class="button outline retry">Try again</button>'),this.loadStatus.find(".retry").on("click",this.load.bind(this))},onMediaAndTagsLoaded:function(){this.renderFilters(),this.renderUploader(),this.renderList(),this.refresh(),this.sidebarElement.addClass("visible"),this.contentElement.addClass("visible"),this.loadStatus.remove()},render:function(){this.domElement=$('<div class="media-library-page"></div>'),this.sidebarElement=$('<div class="media-library-sidebar">').appendTo(this.domElement),this.contentElement=$('<div class="media-library-content">').appendTo(this.domElement)},renderFilters:function(){this.filters=new SL.components.medialibrary.Filters(this.media,this.tags,{editable:this.isEditable(),searchPlaceholder:this.options.searchPlaceholder}),this.filters.filterChanged.add(this.onFilterChanged.bind(this)),this.filters.appendTo(this.sidebarElement)},renderUploader:function(){this.isEditable()&&(this.uploader=new SL.components.medialibrary.Uploader(this.media,{enforceStorageLimit:this.options.enforceStorageLimit,canUploadVideo:this.options.canUploadVideo}),this.uploader.uploadEnqueued.add(this.onUploadEnqueued.bind(this)),this.uploader.uploadStarted.add(this.onUploadStarted.bind(this)),this.uploader.uploadCompleted.add(this.onUploadCompleted.bind(this)),this.uploader.appendTo(this.sidebarElement))},renderList:function(){this.list=new SL.components.medialibrary.List(this.media,this.tags,{editable:this.isEditable()}),this.list.itemSelected.add(this.select.bind(this)),this.list.appendTo(this.contentElement)},setupDragAndDrop:function(){this.dragAndDropInstructions=$(['<div class="media-library-drag-instructions">','<div class="inner">',"Drop to upload media","</div>","</div>"].join("")),this.dragAndDropListener={onDragOver:function(){this.dragAndDropInstructions.appendTo(this.domElement)}.bind(this),onDragOut:function(){this.dragAndDropInstructions.remove()}.bind(this),onDrop:function(t){this.dragAndDropInstructions.remove();var e=t.originalEvent.dataTransfer.files;if(this.isSelecting())this.uploader.enqueue(e[0]);else for(var i=0;i<e.length;i++)this.uploader.enqueue(e[i]);SL.analytics.trackEditor("Media: Upload file","drop from desktop")}.bind(this)}},show:function(t){this.domElement.appendTo(t),this.domElement.addClass("visible"),this.bind()},hide:function(){this.unbind(),this.domElement.detach(),this.domElement.removeClass("visible")},bind:function(){SL.draganddrop.subscribe(this.dragAndDropListener)},unbind:function(){this.dragAndDropInstructions.remove(),SL.draganddrop.unsubscribe(this.dragAndDropListener)},configure:function(t){this.options=$.extend(this.options,t),this.refresh()},refresh:function(){this.media&&this.media.isLoaded()&&(this.list.clearSelection(),this.isSelecting()?(this.list.setPrimaryFilter(this.options.select.filter),this.list.clearSecondaryFilter(),this.filters.hideAllTypesExcept(this.options.select.id,this.options.select.filter),this.filters.selectFilter(this.options.select.id)):(this.filters.showAllTypes(),this.list.clearPrimaryFilter(),this.filters.selectDefaultFilter()))},layout:function(){var t=this.sidebarElement.width();this.contentElement.css({width:this.domElement.width()-t,left:t,paddingLeft:0}),this.list&&this.list.layout()},select:function(t){this.selected.dispatch(t)},isSelecting:function(){return!!this.options.select},isEditable:function(){return!!this.options.editable},onFilterChanged:function(t,e){this.list.setSecondaryFilter(t,e)},onUploadEnqueued:function(t){var e=this.filters.getSelectedFilterData();e.type===SL.components.medialibrary.Filters.FILTER_TYPE_TAG&&t.uploadCompleted.add(function(){this.tags.addTagTo(e.tag,[t])}.bind(this))},onUploadStarted:function(t){this.isSelecting()&&this.options.selectAfterUpload&&this.uploader.getLastSelectedFileCount()<2&&this.options.select.filter(t)&&this.select(t)},onUploadCompleted:function(t){this.media.push(t)},onTagsChanged:function(){}}),SL("components.medialibrary").MediaLibrarySearch=Class.extend({init:function(t){this.options=$.extend({searchLimit:25,idealThumbWidth:260},t),this.sources=[{value:"unsplash",title:"Unsplash",description:"Hundreds of thousands of beautiful high quality photos.",selected:!0,callback:this.onSearchSourceClicked.bind(this,"unsplash")},{value:"giphy",title:"GIPHY",description:"The best animated GIFs in the world.",selected:!0,callback:this.onSearchSourceClicked.bind(this,"giphy")}],this.selected=new signals.Signal,this.selectedSourcesChanged=new signals.Signal,this.search=this.search.bind(this),this.render(),this.restoreSources()},render:function(){this.domElement=$('<div class="media-library-page media-library-search"></div>'),this.searchHeader=$('<div class="search-header"></div>'),this.searchHeader.appendTo(this.domElement),this.searchInputWrapper=$('<div class="search-input-wrapper"></div>'),this.searchInputWrapper.appendTo(this.searchHeader),this.searchInput=$('<input class="search-input" placeholder="Search..." type="text">'),this.searchInput.on("input",$.debounce(this.search,500)),this.searchInput.appendTo(this.searchInputWrapper),this.searchReset=$('<div class="search-reset" data-tooltip="Clear search term"><span class="icon i-x-altx-alt"></span></div>'),this.searchReset.on("vclick",this.onSearchResetClicked.bind(this)),this.searchReset.appendTo(this.searchInputWrapper),this.searchSources=$('<div class="search-sources"><span class="label"></span><span class="icon i-menu"></span></div>'),this.searchSources.on("vclick",this.onSearchSourcesClicked.bind(this)),this.searchSources.appendTo(this.searchInputWrapper),this.searchResults=$('<div class="search-results"></div>'),this.searchResults.on("scroll",$.throttle(this.onScroll.bind(this),200)),this.searchResults.on("click",".search-result",this.onSearchResultClicked.bind(this)),this.searchResults.appendTo(this.domElement),this.renderSearchTypes()},renderSearchTypes:function(){this.sources.forEach(function(t){t.element=$('<div class="search-results-group empty" data-type="'+t.value+'"></div>'),t.element.appendTo(this.searchResults),t.element.data("source",t),t.placeholderElement=$('<div class="search-results-placeholder"><div class="logo"></div><div class="label">'+t.title+"</div></div>"),t.placeholderElement.appendTo(t.element),t.listElement=$('<div class="search-results-list"></div>'),t.listElement.appendTo(t.element),t.spinnerElement=$('<div class="spinner" data-spinner-color="#333"></div>'),t.spinner=SL.util.html.createSpinner({color:"#333"}),t.startSpinner=function(){t.element.removeClass("empty"),t.spinnerElement.appendTo(t.element),t.spinner.spin(t.spinnerElement.get(0))},t.stopSpinner=function(){t.spinner.stop(),t.spinnerElement.detach()},t.masonry=new Masonry(t.listElement.get(0),{itemSelector:".search-result",columnWidth:this.thumbWidth,resize:!1,hiddenStyle:{opacity:0,transform:"scale(0.85)"}})},this)},show:function(t){this.domElement.appendTo(t),this.domElement.addClass("visible")},hide:function(){this.domElement.detach()},configure:function(t){this.options=$.extend(this.options,t),this.refresh()},bind:function(){},unbind:function(){},refresh:function(){this.searchInput.focus(),this.refreshResults()},layout:function(){var t=this.sources.filter(function(t){return t.selected});if(t.length>0){var e=t[0].element.width();this.thumbWidth=Math.floor(e/Math.max(Math.round(e/this.options.idealThumbWidth),1)),t.forEach(function(t){t.listElement.find(".search-result").each(function(t,e){this.setSearchResultSize($(e))}.bind(this)),t.masonry.option({columnWidth:this.thumbWidth}),t.masonry.layout()},this)}},refreshResults:function(t){var e=this.searchResults.scrollTop(),i=200,n=this.searchResults.prop("offsetHeight");(t||this.sources).forEach(function(t){if(t.selected){t.listElement.find(".search-result").each(function(t,s){s=$(s);var o=s.prop("offsetTop"),a=o+s.data("height"),r=a+i>e&&o-i<e+n;r&&!s.data("visible")?s.data("visible",!0).data("mediaElement").appendTo(s):!r&&s.data("visible")&&s.data("visible",!1).data("mediaElement").detach()}.bind(this));var s=t.listElement.height();s>1&&s-e-n<400&&this.loadSearchSource(t)}},this),this.searchHeader.toggleClass("show-scroll-shadow",e>20),this.searchResults.toggleClass("show-scroll-shadow",this.searchResults.prop("scrollHeight")>n+20)},refreshSources:function(){this.sources.forEach(function(t){t.element.toggleClass("hidden",!t.selected),t.selected&&!t.searched&&this.loadSearchSource(t)},this),this.searchSources.find(".label").text(this.getSelectedSourceNames())},restoreSources:function(){var t=SL.current_user.settings.getMediaSourceList();t.length&&this.sources.forEach(function(e){e.selected=t.indexOf(e.value)!==-1},this),this.validateSources(),this.refreshSources()},persistSources:function(){var t=[];this.sources.forEach(function(e){e.selected&&t.push(e.value)}),t=t.join(","),SL.current_user.settings.get("media_sources")!==t&&(SL.current_user.settings.set("media_sources",t),SL.current_user.settings.save(["media_sources"])),this.selectedSourcesChanged.dispatch()},validateSources:function(){var t=this.sources.some(function(t){return t.selected});t===!1&&(this.sources[0].selected=!0,this.refreshSources())},getSelectedSourceNames:function(){var t=this.sources.filter(function(t){return t.selected}).map(function(t){return t.title});return t.join(2===t.length?" & ":", ")},resetSearch:function(){this.searchLimit=this.options.searchLimit,this.sources.forEach(function(t){t.xhr&&(t.xhr.abort(),t.xhr=null),t.element.addClass("empty"),t.element.find(".error").remove(),t.masonry.remove(t.listElement.find(".search-result")),t.masonry.layout(),t.listElement.empty().height(0),t.searchOffset=0,t.searched=!1,t.locked=!1},this)},search:function(){this.resetSearch(),this.searchTerm=this.searchInput.val().trim();var t=!(!this.searchTerm||""===this.searchTerm);this.searchInput.toggleClass("has-value",t),t&&(this.thumbWidth||this.layout(),this.sources.forEach(this.loadSearchSource,this))},loadSearchSource:function(t){this.searchTerm&&t.selected&&!t.locked&&!t.xhr&&(t.searched=!0,t.startSpinner(),t.xhr=$.ajax({type:"GET",url:SL.endpoints.SEARCH_MEDIA,context:this,data:{q:this.searchTerm,type:t.value,limit:this.searchLimit,offset:t.searchOffset}}).done(function(e){0===e.results.length?(0===t.listElement.find(".search-result").length&&t.element.append('<p class="error">No results</p>'),t.locked=!0):(t.searchOffset+=this.searchLimit,this.appendSearchResults(e.results,t))}).fail(function(){t.element.append('<p class="error">An error occured while fetching search results.</p>'),t.locked=!0}).always(function(){t.stopSpinner(),t.xhr=null}))},appendSearchResults:function(t,e){var i=[];t.forEach(function(t){var n=this.renderSearchResult(t,e);n&&n.length&&i.push(n.get(0))},this),i.length&&(e.masonry.appended(i),e.masonry.layout(),setTimeout(function(){this.refreshResults([e])}.bind(this),1))},renderSearchResult:function(t,e){if(t.thumb_url&&t.url){var i=$('<div class="search-result"></div>').data("resultData",t),n=210+Math.round(30*Math.random()),s=n,o=n;i.css("background-color","rgb("+n+","+s+","+o+")"),t.meta&&"string"==typeof t.meta.creator_name&&("string"==typeof t.meta.profile_url?i.append('<a class="search-result-attribution" target="_blank" href="'+t.meta.profile_url+'"><span class="name">'+t.meta.creator_name+"</span></a>"):i.append('<div class="search-result-attribution"><span class="name">'+t.meta.creator_name+"</span></div>")),this.setSearchResultSize(i);var a=t.thumb_url;return Modernizr.webpanimation&&t.webp_thumb_url&&(a=t.webp_thumb_url),i.data("mediaElement",$('<img class="search-result-media" src="'+a+'">')),i.appendTo(e.listElement),i}},setSearchResultSize:function(t){var e=t.data("resultData");if(e&&e.width&&e.height){var i=this.thumbWidth,n=Math.floor(e.height*(this.thumbWidth/e.width));t.css({width:i,height:n}),t.data({width:i,height:n})}},getSearchSourceByValue:function(t){return this.sources.filter(function(e){return e.value===t}).shift()},onScroll:function(){this.refreshResults()},onSearchResultClicked:function(t){if(0===$(t.target).closest(".search-result-attribution").length){var e=$(t.target).closest(".search-result").data("resultData");e&&("string"==typeof e.download_url&&$.ajax({url:e.download_url,type:"POST"}),this.selected.dispatch(e.url))}},onSearchSourcesClicked:function(t){var e=SL.prompt({anchor:$(t.currentTarget),maxWidth:280,title:"Sources",type:"list",alignment:"b",data:this.sources,listType:"multiselect",optional:!0});this.sources.map(function(t){return t.selected});e.destroyed.add(function(){this.validateSources(),this.persistSources(),this.refreshResults()}.bind(this))},onSearchSourceClicked:function(t){var e=this.getSearchSourceByValue(t);e&&(e.selected=!e.selected,this.searchResults.scrollTop(0),this.refreshSources(),this.layout(),this.refreshResults())},onSearchResetClicked:function(){this.searchInput.val("").focus(),this.search(),this.searchHeader.removeClass("show-scroll-shadow"),this.searchResults.removeClass("show-scroll-shadow")}}),SL("components.medialibrary").MediaLibrary=SL.components.popup.Popup.extend({TYPE:"media-library",init:function(t){this._super($.extend({width:1110,height:800,singleton:!0,headerActions:[]},t)),this.selected=new signals.Signal,this.selectedExternal=new signals.Signal},render:function(){if(this._super(),this.innerElement.addClass("media-library"),this.innerElement.append('<div class="dragging-media-overlay"></div>'),this.renderTabs(),this.userPage=new SL.components.medialibrary.MediaLibraryPage(new SL.collections.Media,new SL.collections.MediaTags,{searchPlaceholder:"Search my uploads...",enforceStorageLimit:SL.current_user.hasStorageLimit(),canUploadVideo:SL.editor.controllers.Capabilities.canUploadVideo()}),this.userPage.selected.add(this.onMediaSelected.bind(this)),this.userPage.load(),this.userPage.tab=this.userTab,SL.current_user.isEnterprise()){var t=new SL.collections.TeamMedia;t.loadCompleted.add(function(){!SL.current_user.isEnterpriseManager()&&t.isEmpty()&&(this.teamTab.addClass("is-disabled"),this.teamTab.attr("data-tooltip","Your team doesn't have any shared media yet.<br>Only admins can upload team media."))}.bind(this)),t.loadFailed.add(function(){this.teamTab.attr("data-tooltip","Failed to load")}.bind(this)),this.teamPage=new SL.components.medialibrary.MediaLibraryPage(t,new SL.collections.TeamMediaTags,{searchPlaceholder:"Search team media..",editable:SL.current_user.isEnterpriseManager(),selectAfterUpload:!1}),this.teamPage.selected.add(this.onMediaSelected.bind(this)),this.teamPage.load(),this.teamPage.tab=this.teamTab}this.searchPage=new SL.components.medialibrary.MediaLibrarySearch,this.searchPage.selected.add(this.onSearchURLSelected.bind(this)),this.searchPage.selectedSourcesChanged.add(this.refreshSearchSources.bind(this)),this.searchPage.tab=this.searchTab,this.showUserPage()},renderTabs:function(){this.headerTabs=$('<div class="media-library-header-tabs"></div>'),this.headerTabsWrapper=$('<div class="media-library-header-tabs-wrapper"></div>').appendTo(this.headerTabs),this.userTab=$('<div class="media-library-header-tab user-tab"><span class="icon i-user"></span> My Uploads</div>').appendTo(this.headerTabsWrapper),this.userTab.on("vclick",this.showUserPage.bind(this)),SL.current_user.isEnterprise()&&(this.teamTab=$('<div class="media-library-header-tab team-tab" data-tooltip-alignment="r"><span class="icon i-users"></span> Team Media</div>').appendTo(this.headerTabsWrapper),this.teamTab.on("vclick",this.showTeamPage.bind(this))),this.searchTab=$('<div class="media-library-header-tab search-tab"><span class="icon i-magnifying-glass"></span> Search <span class="search-sources"></span></div>').appendTo(this.headerTabsWrapper),this.searchTab.on("vclick",this.showSearchPage.bind(this)),this.headerTabs.insertAfter(this.headerTitleElement),this.headerTabs.find(".media-library-header-tab").append('<span class="arrow"></span>')},showPage:function(t){this.currentPage&&this.currentPage.hide(),this.headerTabs.find(".is-selected").removeClass("is-selected"),this.currentPage=t,t.show(this.bodyElement),t.configure(this.options),t.tab.addClass("is-selected"),this.refresh(),this.layout()},showUserPage:function(t){t&&t.preventDefault(),this.showPage(this.userPage)},showTeamPage:function(t){t&&t.preventDefault(),this.showPage(this.teamPage)},showSearchPage:function(t){t&&t.preventDefault(),this.showPage(this.searchPage)},open:function(t){t=$.extend({select:null,selectExternal:!1,selectExternalValue:"",selectExternalLabel:"Insert from URL"},t),this._super(t),this.currentPage.configure(t),this.currentPage.bind(),this.refresh(),this.layout()},close:function(){this._super.apply(this,arguments),this.selected.removeAll(),this.selectedExternal.removeAll(),this.currentPage.unbind()},layout:function(){this._super.apply(this,arguments),this.currentPage.layout()},refresh:function(){this.refreshHeader(),this.options.select&&this.options.selectExternal?this.replaceAdditionalHeaderActions([{label:"",className:"outline icon i-link",tooltip:this.options.selectExternalLabel,callback:this.onExternalURLClicked.bind(this)},{label:"",className:"grey icon i-x",callback:this.close.bind(this)}]):this.replaceAdditionalHeaderActions([{label:"",className:"grey icon i-x",callback:this.close.bind(this)}]),this.currentPage!==this.searchPage||this.searchTab.is(":visible")?this.currentPage.refresh():this.showUserPage()},refreshHeader:function(){var t=this.options.select===SL.models.Media.VIDEO;t&&!this.teamPage?(this.options.title="Select Video",this.headerTabs.hide()):t&&this.teamPage?(this.options.title="",this.headerTabs.show(),this.searchTab.hide()):(this.options.title="",this.headerTabs.show(),this.searchTab.show()),this.refreshTitle(),this.refreshSearchSources()},refreshSearchSources:function(){this.searchTab.find(".search-sources").text(this.searchPage.getSelectedSourceNames())},isSelecting:function(){return!!this.options.select},onMediaSelected:function(t){this.isSelecting()?this.selected.dispatch(t):SL.editor.controllers.Blocks.add({type:t.has("type")?t.get("type").toLowerCase():"image",afterInit:function(e){setTimeout(function(){e.setMediaModel(t)},1)}}),this.close()},onSearchURLSelected:function(t){this.isSelecting()?this.selectedExternal.dispatch(encodeURI(t)):SL.editor.controllers.Blocks.add({type:"image",afterInit:function(e){e.set("image.src",t)}}),this.close()},onExternalURLClicked:function(){this.domElement.removeClass("visible");var t=SL.prompt({title:this.options.selectExternalLabel,subtitle:"Enter a direct URL to the file you want to include. Please use HTTPS protocol to ensure that the file can load in all presentation views.",type:"input",confirmLabel:"Save",data:{value:this.options.selectExternalValue,placeholder:"https://...",autoselect:!0,width:480}});t.confirmed.add(function(t){this.selectedExternal.dispatch(encodeURI(t)),this.close()}.bind(this)),t.canceled.add(function(){this.domElement.addClass("visible")}.bind(this))}}),SL("components.medialibrary").Uploader=Class.extend({MAX_CONCURRENT_UPLOADS:2,IMAGE_FORMAT:{validator:/image.*/,maxSize:function(){return SL.current_user.get("image_upload_limit")}},VIDEO_FORMAT:{validator:/video.*/,maxSize:function(){return SL.current_user.get("video_upload_limit")}},init:function(t,e){this.media=t,this.options=$.extend({multiple:!0,enforceStorageLimit:!1,canUploadVideo:!0},e),this.queue=new SL.collections.Collection,this.lastSelectionFileCount=0,this.FILE_FORMATS=[this.IMAGE_FORMAT],this.options.canUploadVideo&&this.FILE_FORMATS.push(this.VIDEO_FORMAT),this.render(),this.renderInput(),this.bind(),this.refresh()},bind:function(){this.onUploadCompleted=this.onUploadCompleted.bind(this),this.onUploadFailed=this.onUploadFailed.bind(this),this.uploadEnqueued=new signals.Signal,this.uploadStarted=new signals.Signal,this.uploadCompleted=new signals.Signal},render:function(){this.domElement=$('<div class="media-library-uploader">'),this.uploadButton=$('<div class="media-library-uploader-button"><span class="label">Upload</span><span class="icon i-cloud-upload2"></span></div>'),this.uploadButton.appendTo(this.domElement),this.uploadExceededButton=$('<a class="media-library-uploader-exceeded" href="'+SL.routes.PRICING+'" target="_blank"><span class="label">Storage limit reached.<br>Click for upgrade options.</span></a>'),this.uploadExceededButton.appendTo(this.domElement),this.uploadList=$('<div class="media-library-uploader-list">'),this.uploadList.appendTo(this.domElement),SL.current_user.hasStorageLimit()&&this.options.enforceStorageLimit&&this.renderStorageLimit()},renderInput:function(){this.fileInput&&this.fileInput.remove(),this.fileInput=$('<input class="file-input" type="file">'),this.fileInput.on("change",this.onInputChanged.bind(this)),this.fileInput.appendTo(this.uploadButton),this.options.multiple?this.fileInput.attr("multiple","multiple"):this.fileInput.removeAttr("multiple","multiple")},renderStorageLimit:function(){this.uploadLimit=$("<a/>",{"class":"media-library-uploader-limit",href:SL.routes.PRICING,target:"_blank","data-tooltip":"Storage limit on your current plan.<br>Click for upgrade options.","data-tooltip-alignment":"t","data-tooltip-delay":"1000"}),this.uploadLimit.append('<div class="sl-meter"></div>'),this.uploadLimit.appendTo(this.domElement),this.storageMeter=new SL.components.Meter(this.uploadLimit.find(".sl-meter"),{value:SL.current_user.get("storage_used"),total:SL.current_user.get("storage_limit"),negativeThreshold:.8,warningThreshold:.6}),SL.current_user.watch("storage_used",this.refresh.bind(this))},refresh:function(){this.storageMeter?(this.storageMeter.setValue(SL.current_user.get("storage_used")),this.domElement.toggleClass("storage-limit-exceeded",SL.current_user.isExceedingStorageLimit())):this.domElement.removeClass("storage-limit-exceeded")},configure:function(t){this.options=$.extend(this.options,t),this.renderInput()},appendTo:function(t){this.domElement.appendTo(t)},isUploading:function(){return this.queue.some(function(t){return t.isUploading()})},validateFile:function(t){var e="number"==typeof t.size?t.size:0;return this.FILE_FORMATS.some(function(i){return!!t.type.match(i.validator)&&!("function"==typeof i.maxSize&&e>i.maxSize())})},enqueue:function(t){if(this.queue.size()>=100)return SL.notify("Upload queue is full, please wait","negative"),!1;var e=SL.models.Media.getTypeFromContentType(t.type),i=new SL.models.Media.create({type:e},this.media.crud,t);i.uploaderElement=$(['<div class="media-library-uploader-item">','<div class="item-text">','<span class="status"><span class="icon i-clock"></span></span>','<span class="filename">'+(t.name||"untitled")+"</span>","</div>",'<div class="item-progress">','<span class="bar"></span>',"</div>","</div>"].join("")),i.uploaderElement.appendTo(this.uploadList),setTimeout(i.uploaderElement.addClass.bind(i.uploaderElement,"animate-in"),1),i.uploadCompleted.add(this.onUploadCompleted),i.uploadFailed.add(this.onUploadFailed),i.uploadProgressed.add(function(t){var e="scaleX("+t+")";i.uploaderElement.find(".bar").css({"-webkit-transform":e,"-moz-transform":e,transform:e})}.bind(this)),this.queue.push(i),this.uploadEnqueued.dispatch(i),this.checkQueue()},dequeue:function(t,e,i){var n=t.uploaderElement;n&&(t.uploaderElement=null,n.addClass(e),n.find(".status").html(i),setTimeout(function(){n.removeClass("animate-in").addClass("animate-out"),setTimeout(n.remove.bind(n),500)}.bind(this),2e3),this.queue.remove(t),t.isUploaded()&&(this.uploadCompleted.dispatch(t),t.hasPostProcessingStep()?(t.processingStarted.add(this.checkStorage.bind(this)),t.processingFailed.add(this.checkStorage.bind(this))):this.checkStorage()))},checkQueue:function(){this.queue.forEach(function(t){t.isUploaded()?this.dequeue(t,"completed",'<span class="icon i-checkmark"></span>'):t.isUploadFailed()&&this.dequeue(t,"failed",'<span class="icon i-denied"></span>')}.bind(this));var t=0;this.queue.forEach(function(e){t<this.MAX_CONCURRENT_UPLOADS&&(e.isUploading()?t+=1:e.isWaitingToUpload()&&(e.upload(),e.uploaderElement.find(".status").html('<div class="upload-spinner"></div>'),t+=1,this.uploadStarted.dispatch(e)))}.bind(this)),this.domElement.toggleClass("is-uploading",t>0)},checkStorage:function(){SL.current_user.updateStorageUsed()},getLastSelectedFileCount:function(){return this.lastSelectionFileCount},onUploadCompleted:function(){this.checkQueue()},onUploadFailed:function(t){SL.notify(t||"An error occurred while uploading your file.","negative"),this.checkQueue()},onInputChanged:function(t){var e=SL.util.toArray(this.fileInput.get(0).files);if(e=e.filter(this.validateFile.bind(this)),e.length)this.lastSelectionFileCount=e.length,e.forEach(this.enqueue.bind(this)),SL.analytics.trackEditor("Media: Upload file","file input");else{var i=SL.util.math.bytesToMegabytes(SL.current_user.get("image_upload_limit"),!0),n=SL.util.math.bytesToMegabytes(SL.current_user.get("video_upload_limit"),!0);this.options.canUploadVideo?SL.notify("Invalid file. You can upload <strong>PNG</strong>/<strong>JPG</strong>/<strong>GIF</strong>/<strong>SVG</strong> images up to <strong>"+i+" MB</strong> and videos up to <strong>"+n+" MB</strong>.","negative"):SL.notify("Invalid file. You can upload <strong>PNG</strong>/<strong>JPG</strong>/<strong>GIF</strong>/<strong>SVG</strong> images up to <strong>"+i+" MB</strong>","negative")}this.renderInput(),t.preventDefault()},destroy:function(){this.queue=null,this.uploadStarted.dispose(),this.uploadCompleted.dispose()}}),SL("components").Menu=Class.extend({init:function(t){if(this.config=$.extend({alignment:"auto",anchorSpacing:10,minWidth:0,offsetX:0,offsetY:0,options:[],showOnHover:!1,showOnHoverCondition:null,mouseLeaveDelay:0,destroyOnHide:!1,touch:/(iphone|ipod|ipad|android|windows\sphone)/gi.test(navigator.userAgent)},t),this.config.anchor=$(this.config.anchor),this.show=this.show.bind(this),this.hide=this.hide.bind(this),this.layout=this.layout.bind(this),this.toggle=this.toggle.bind(this),this.onMouseOver=this.onMouseOver.bind(this),this.onDocumentMouseMove=this.onDocumentMouseMove.bind(this),this.onDocumentMouseDown=this.onDocumentMouseDown.bind(this),this.onDocumentKeydown=this.onDocumentKeydown.bind(this),this.onAnchorFocus=this.onAnchorFocus.bind(this),this.onAnchorBlur=this.onAnchorBlur.bind(this),this.onAnchorFocusKeyDown=this.onAnchorFocusKeyDown.bind(this),this.submenus=[],this.destroyed=new signals.Signal,this.render(),this.renderList(),this.config.anchor.length)if(this.config.touch)this.config.anchor.addClass("menu-show-on-touch"),this.config.anchor.on("touchstart pointerdown",$.debounce(function(t){t.preventDefault(),this.toggle()}.bind(this),50,!0)),this.config.anchor.on("click",function(t){t.preventDefault()}.bind(this));else{if(this.config.showOnHover){this.config.anchor.on("focus",this.onAnchorFocus),this.config.anchor.on("blur",this.onAnchorBlur),this.config.anchor.on("mouseover",this.onMouseOver);try{this.config.anchor.is(":hover")&&this.onMouseOver()}catch(t){}}this.config.anchor.on("click",this.toggle)}},render:function(){this.domElement=$('<div class="sl-menu">'),this.listElement=$('<div class="sl-menu-list">').appendTo(this.domElement),this.arrowElement=$('<div class="sl-menu-arrow">').appendTo(this.domElement),
this.arrowFillElement=$('<div class="sl-menu-arrow-fill">').appendTo(this.arrowElement),this.hitarea1=$('<div class="sl-menu-hitarea">'),this.hitareaPath=document.createElementNS("http://www.w3.org/2000/svg","path"),this.hitarea2=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.hitarea2.setAttribute("class","sl-menu-hitarea"),this.hitarea2.appendChild(this.hitareaPath),this.domElement.append(this.hitarea1,this.hitarea2),this.listElement.css("minWidth",this.config.minWidth+"px"),SL.util.getDebugLevel()>1&&this.domElement.addClass("debug")},renderList:function(){this.config.options.forEach(function(t){var e;"string"==typeof t.url?(e=$('<a class="sl-menu-item" href="'+t.url+'">'),"string"==typeof t.urlTarget&&e.attr("target",t.urlTarget)):e=$('<button class="sl-menu-item">'),e.html('<span class="label">'+t.label+"</span>"),e.data("callback",t.callback),e.appendTo(this.listElement),e.on("click",function(t){var e=$(t.currentTarget),i=e.data("callback");"function"==typeof i&&i.apply(null,[t]),this.hide()}.bind(this)),t.icon&&e.append('<span class="icon i-'+t.icon+'"></span>'),t.attributes&&e.attr(t.attributes),"string"==typeof t.className&&e.addClass(t.className),t.iconHTML&&e.append(t.iconHTML),t.submenu&&!this.config.touch&&this.submenus.push(new SL.components.Menu({anchor:e,anchorSpacing:10,alignment:t.submenuAlignment||"rl",minWidth:t.submenuWidth||160,showOnHover:!0,options:t.submenu}))}.bind(this)),this.listElement.find(".sl-menu-item:not(:last-child)").after('<div class="sl-menu-divider">')},bind:function(){SL.keyboard.keydown(this.onDocumentKeydown),$(window).on("resize scroll",this.layout),$(document).on("mousedown touchstart pointerdown",this.onDocumentMouseDown)},unbind:function(){SL.keyboard.release(this.onDocumentKeydown),SL.keyboard.release(this.onAnchorFocusKeyDown),$(window).off("resize scroll",this.layout),$(document).off("mousedown touchstart pointerdown",this.onDocumentMouseDown)},layout:function(){if(0!==this.config.anchor.length){var t=this.config.anchor.offset(),e=this.config.anchorSpacing,i=this.config.alignment,n=$(window).scrollLeft(),s=$(window).scrollTop(),o=t.left+this.config.offsetX,a=t.top+this.config.offsetY,r=this.config.anchor.outerWidth(),l=this.config.anchor.outerHeight(),d=this.domElement.outerWidth(),c=this.domElement.outerHeight(),h=1,u=d/2,p=d/2,m=8;switch("auto"===i&&(i=t.top-(c+e+m)<s?"b":"t"),"rl"===i&&(i=t.left+r+e+m+d<window.innerWidth?"r":"l"),this.domElement.attr("data-alignment",i),i){case"t":o+=(r-d)/2,a-=c+e;break;case"b":o+=(r-d)/2,a+=l+e;break;case"l":o-=d+e,a+=(l-c)/2;break;case"r":o+=r+e,a+=(l-c)/2}switch(o=Math.min(Math.max(o,n+e),$(window).width()+n-d-e),a=Math.min(Math.max(a,s+e),window.innerHeight+s-c-e),i){case"t":u=t.left-o+r/2,p=c-2*h;break;case"b":u=t.left-o+r/2,p=-m;break;case"l":u=d-2*h,p=t.top-a+l/2;break;case"r":u=-m,p=t.top-a+l/2}this.domElement.css({left:Math.round(o),top:Math.round(a)}),this.arrowElement.css({left:Math.round(u),top:Math.round(p)}),this.hitarea1.css({top:-8,right:-8,bottom:-8,left:-8});var f,g,v=t.left-o,b=t.top-a;"t"===i||"b"===i?(f=Math.max(d,r),g=c+l+e,this.hitarea2.style.left=(d-f)/2+"px",v+=Math.max((r-d)/2,0),"t"===i?(this.hitarea2.style.top="0px",this.hitareaPath.setAttribute("d",["M",(f-d)/2,c,"S",v,b,",",v,b+l,"L",v,b,"L",v+r,b,"L",v+r,b+l,"S",v+r,b,",",(f+d)/2,c].join(" "))):"b"===i&&(this.hitarea2.style.top=b+"px",this.hitareaPath.setAttribute("d",["M",(f-d)/2,l+e,"S",v,l,",",v,0,"L",v,l,"L",v+r,l,"L",v+r,0,"S",v+r,l,",",(f+d)/2,l+e].join(" ")))):"l"!==i&&"r"!==i||(f=d+r+e,g=Math.max(c,l),this.hitarea2.style.top=(c-g)/2+"px",b+=Math.max((l-c)/2,0),"l"===i?(this.hitarea2.style.left="0px",this.hitareaPath.setAttribute("d",["M",d,(g-c)/2,"S",v,b,",",v+r,b,"L",v,b,"L",v,b+l,"L",v+r,b+l,"S",v,b+l,",",d,(g+c)/2].join(" "))):"r"===i&&(this.hitarea2.style.left=v+"px",this.hitareaPath.setAttribute("d",["M",o-t.left,(g-c)/2,"S",o-t.left,b,",",0,b,"L",0,b,"L",o-t.left-e,b,"L",o-t.left-e,b+l,"L",0,b+l,"S",o-t.left,b+l,",",o-t.left,(g+c)/2].join(" ")))),this.hitarea2.setAttribute("width",f),this.hitarea2.setAttribute("height",g)}},focus:function(t){var e=this.listElement.find(":focus");if(e.length){var i=t>0?e.nextAll(".sl-menu-item").first():e.prevAll(".sl-menu-item").first();i.length&&i.focus()}else this.listElement.find(".sl-menu-item").first().focus()},show:function(){this.focusBefore=$(":focus"),this.domElement.appendTo(document.body),this.config.anchor.addClass("menu-is-open"),this.layout(),this.bind()},hide:function(){this.config.anchor.removeClass("menu-is-open"),this.domElement.detach(),this.unbind(),this.focusBefore&&this.focusBefore.length&&"BODY"===document.activeElement.tagName&&(this.focusBefore.focus(),this.focusBefore=null),$(document).off("mousemove",this.onDocumentMouseMove),this.isMouseOver=!1,clearTimeout(this.hideTimeout),this.config.destroyOnHide===!0&&this.destroy()},toggle:function(){this.isVisible()?this.hide():this.show()},isVisible:function(){return this.domElement.parent().length>0},hasSubMenu:function(){return this.submenus.length>0},destroy:function(){this.destroyed.dispatch(),this.destroyed.dispose(),this.domElement.remove(),this.unbind(),this.config.anchor.off("click",this.toggle),this.config.anchor.off("hover",this.toggle),this.config.anchor.off("focus",this.onAnchorFocus),this.config.anchor.off("blur",this.onAnchorBlur),this.config.anchor.off("mouseover",this.onMouseOver),this.submenus.forEach(function(t){t.destroy()})},onDocumentKeydown:function(t){if(27===t.keyCode)return this.hide(),t.preventDefault(),!1;if(13===t.keyCode){var e=this.listElement.find(":focus");if(e.length){var i=e.attr("href");return"string"==typeof i&&i.length>2?window.location.href=i:e.trigger("click"),t.preventDefault(),!1}}else 38===t.keyCode?(this.focus(-1),t.preventDefault()):40===t.keyCode?(this.focus(1),t.preventDefault()):9===t.keyCode&&t.shiftKey?(this.focus(-1),t.preventDefault()):9===t.keyCode&&(this.focus(1),t.preventDefault());return!0},onMouseOver:function(){this.isMouseOver||SL.pointer.isDown()||("function"!=typeof this.config.showOnHoverCondition||this.config.showOnHoverCondition())&&($(document).on("mousemove",this.onDocumentMouseMove),this.hideTimeout=-1,this.isMouseOver=!0,this.show())},onDocumentMouseMove:function(t){var e=$(t.target),i=0===e.closest(this.domElement).length&&0===e.closest(this.config.anchor).length;this.hasSubMenu()&&(i=0===e.closest(".sl-menu").length&&0===e.closest(this.config.anchor).length),i?this.config.mouseLeaveDelay>0?this.hideTimeout===-1&&(clearTimeout(this.hideTimeout),this.hideTimeout=setTimeout(this.hide,this.config.mouseLeaveDelay)):this.hide():this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=-1)},onDocumentMouseDown:function(t){var e=$(t.target);this.isVisible()&&0===e.closest(this.domElement).length&&0===e.closest(this.config.anchor).length&&this.hide()},onAnchorFocus:function(){this.isMouseOver||SL.keyboard.keydown(this.onAnchorFocusKeyDown)},onAnchorBlur:function(){SL.keyboard.release(this.onAnchorFocusKeyDown)},onAnchorFocusKeyDown:function(t){return!!(this.isMouseOver||13!==t.keyCode&&32!==t.keyCode&&40!==t.keyCode)||(this.show(),this.focus(),SL.keyboard.release(this.onAnchorFocusKeyDown),!1)}}),SL("components").Meter=Class.extend({init:function(t,e){this.options=$.extend({type:"storage",value:0,total:0,negativeThreshold:.9,warningThreshold:.7},e),this.domElement=$(t),this.labelElement=$('<div class="label">').appendTo(this.domElement),this.progressElement=$('<div class="progress">').appendTo(this.domElement),this.format(),this.paint(),this.domElement.addClass("animated")},format:function(){switch(this.unit="",this.value=this.options.value,this.total=this.options.total,this.options.type){case"storage":var t=1024,e=1024*t,i=1024*e;this.value<e&&this.total<e&&(this.value=Math.round(this.value/t),this.total=Math.round(this.total/t),this.unit="KB"),this.value<i&&this.total<i?(this.value=Math.round(this.value/e),this.total=Math.round(this.total/e),this.unit="MB"):(this.value=(this.value/i).toFixed(2),this.total=(this.total/i).toFixed(2),this.unit="GB")}},paint:function(){var t=Math.min(Math.max(this.value/this.total,0),1)||0;this.labelElement.text(this.value+" / "+this.total+" "+this.unit),this.progressElement.width(100*t+"%"),0===this.total?this.domElement.attr("data-state","invalid"):t>this.options.negativeThreshold?this.domElement.attr("data-state","negative"):t>this.options.warningThreshold?this.domElement.attr("data-state","warning"):this.domElement.attr("data-state","positive")},setValue:function(t){this.options.value=t,this.format(),this.paint()},setTotal:function(t){this.options.total=t,this.format(),this.paint()}}),SL("components").ModeTray=Class.extend({init:function(t){this.options=$.extend({type:"",html:""},t),this.render()},render:function(){this.domElement=$('<div class="sl-mode-tray">').addClass(this.options.type),this.innerElement=$('<div class="inner">').appendTo(this.domElement),this.innerElement.html(this.options.html)},find:function(){return this.domElement.find.apply(this.domElement,arguments)},show:function(t){this.domElement.appendTo(t||document.body),this.domElement.addClass("visible")},hide:function(){this.domElement.removeClass("visible").detach()},setState:function(t){this.state!==t&&(this.state=t,"string"!=typeof t||""===t?this.domElement.removeAttr("data-state"):this.domElement.attr("data-state",t))},destroy:function(){this.domElement.remove()}}),SL("components").Notification=Class.extend({init:function(t,e){this.html=t,this.options=$.extend({id:null,type:"",duration:2500+20*this.html.length,optional:!0,buttons:null,buttonStyle:"white"},e),"negative"===this.options.type&&(this.options.duration=1.5*this.options.duration),this.destroyed=new signals.Signal,this.hideTimeout=-1,"string"==typeof this.options.id&&$('.sl-notification[data-id="'+this.options.id+'"]').remove(),this.render(),this.bind(),this.show(),this.layout()},render:function(){0===$(".sl-notifications").length&&$(document.body).append('<div class="sl-notifications"></div>'),this.domElement=$('<p class="sl-notification">').html(this.html).addClass(this.options.type).toggleClass("persistent",!this.options.optional),"string"==typeof this.options.id&&this.domElement.attr("data-id",this.options.id);var t=$(".sl-notifications"),e=t.find(".sl-notification.persistent");this.options.optional&&e.length?this.domElement.insertBefore(e.first()):this.domElement.appendTo(t),this.hasButtons()&&(this.buttonsElement=$('<div class="buttons"></div>').appendTo(this.domElement),this.buttonsElement.attr("data-layout",this.options.buttonsLayout||"block"),this.options.buttons.forEach(this.renderButton,this))},hasButtons:function(){return this.options.buttons&&this.options.buttons.length>0},renderButton:function(t){$('<button class="button"></button>').html(t.label).addClass(t.className||"white").appendTo(this.buttonsElement).on("click",function(){this.destroy(),"function"==typeof t.callback&&t.callback()}.bind(this))},bind:function(){this.hide=this.hide.bind(this),this.destroy=this.destroy.bind(this),this.options.optional&&(this.domElement.on("mouseenter",this.stopTimeout.bind(this)),this.domElement.on("mouseleave",this.startTimeout.bind(this)),this.hasButtons()||this.domElement.on("click",this.destroy.bind(this)))},startTimeout:function(){this.stopTimeout(),this.hideTimeout=setTimeout(this.hide,this.options.duration)},stopTimeout:function(){clearTimeout(this.hideTimeout)},show:function(){this.isDestroyed!==!0&&setTimeout(function(){this.domElement.addClass("show"),this.options&&this.options.optional&&this.startTimeout()}.bind(this),1)},hide:function(){this.domElement.addClass("hide"),this.hideTimeout=setTimeout(this.destroy.bind(this),400),this.layout()},layout:function(){var t=0;$(".sl-notification:not(.hide)").get().reverse().forEach(function(e){t-=$(e).outerHeight()+10,e.style.top=t+"px"})},destroy:function(){clearTimeout(this.hideTimeout),this.isDestroyed=!0,this.options=null,this.domElement.remove(),this.layout(),this.destroyed.dispatch(),this.destroyed.dispose(),this.destroy=function(){}}}),SL.components.RetryNotification=SL.components.Notification.extend({init:function(t,e){e=$.extend({optional:!1},e),this._super(t,e),this.retryClicked=new signals.Signal},render:function(){this._super(),this.retryOptions=$('<div class="retry-options"></div>'),this.retryOptions.appendTo(this.domElement),this.retryMessage=$('<div class="retry-countdown"></div>'),this.retryButton=$('<button class="button white retry-button">Retry</button>'),this.retryButton.on("vclick",this.onRetryClicked.bind(this)),this.retryButton.appendTo(this.retryOptions)},bind:function(){this._super(),this.updateCountdown=this.updateCountdown.bind(this)},startCountdown:function(t){clearInterval(this.updateInterval),this.retryStart=Date.now(),this.retryDuration=t,this.updateInterval=setInterval(this.updateCountdown,250),this.updateCountdown(),this.retryMessage.prependTo(this.retryOptions),this.layout()},updateCountdown:function(){var t=this.retryDuration-(Date.now()-this.retryStart);t/=1e3,this.retryDuration<2e3||t<=0?this.retryMessage.text("Retrying..."):this.retryMessage.text("Retrying in "+Math.ceil(t)+"s")},disableCountdown:function(){clearInterval(this.updateInterval),this.retryMessage.remove(),this.layout()},onRetryClicked:function(){this.retryClicked.dispatch()},destroy:function(){clearInterval(this.updateInterval),this.retryClicked&&(this.retryClicked.dispose(),this.retryClicked=null),this._super()}}),SL.components.UndoNotification=SL.components.Notification.extend({init:function(t,e){e=$.extend({buttonsLayout:"inline",buttons:[{label:"Undo",callback:function(){SL.editor.controllers.History.undo()}}]},e),this._super(t,e)}}),SL.notify=function(t,e){return $(".sl-notifications .sl-notification").last().html()===t&&$(".sl-notifications .sl-notification").last().remove(),"string"==typeof e&&(e={type:e}),new SL.components.Notification(t,e)},SL("components").Prompt=Class.extend({init:function(t){this.config=$.extend({type:"custom",data:null,anchor:null,title:null,subtitle:null,bodyText:null,optional:!0,alignment:"auto",minWidth:null,maxWidth:null,offsetX:0,offsetY:0,className:null,confirmOnEnter:!0,destroyAfterConfirm:!0,closeOnClickOutside:!0,confirmLabel:"OK",cancelLabel:"Cancel",confirmButton:null,cancelButton:null,hoverTarget:null,hoverClass:"hover",overlayOpacity:.4,windowSpacing:10,pointerEvents:"auto"},t),this.onBackgroundClicked=this.onBackgroundClicked.bind(this),this.onDocumentKeydown=this.onDocumentKeydown.bind(this),this.onPromptCancelClicked=this.onPromptCancelClicked.bind(this),this.onPromptConfirmClicked=this.onPromptConfirmClicked.bind(this),this.checkInputStatus=this.checkInputStatus.bind(this),this.layout=this.layout.bind(this),this.asyncLayout=this.asyncLayout.bind(this),this.confirmed=new signals.Signal,this.canceled=new signals.Signal,this.destroyed=new signals.Signal,this.render()},render:function(){this.domElement=$('<div class="sl-prompt" data-type="'+this.config.type+'">'),this.backgroundElement=$('<div class="sl-prompt-background">').appendTo(this.domElement),this.wrapperElement=$('<div class="sl-prompt-wrapper">').appendTo(this.domElement),this.wrapperElement.css("pointer-events",this.config.pointerEvents),this.innerElement=$('<div class="sl-prompt-inner">').appendTo(this.wrapperElement),this.arrowElement=$('<div class="sl-prompt-arrow">').appendTo(this.wrapperElement),this.backgroundElement.css("background-color","rgba(0, 0, 0, "+this.config.overlayOpacity+")"),this.domElement.toggleClass("close-on-click-outside",this.config.closeOnClickOutside),this.domElement.toggleClass("transform-positioning",this.useTransformPositioning()),this.config.title&&(this.titleElement=$('<h3 class="title">').html(this.config.title).appendTo(this.innerElement)),this.config.subtitle&&(this.subtitleElement=$('<h4 class="subtitle">').html(this.config.subtitle).appendTo(this.innerElement),this.titleElement&&this.titleElement.addClass("has-subtitle")),this.config.bodyText&&(this.bodyTextElement=$('<h4 class="body-text">').html(this.config.bodyText).appendTo(this.innerElement),this.titleElement&&this.titleElement.addClass("has-body-text")),this.config.className&&this.domElement.addClass(this.config.className),this.config.html&&this.innerElement.append("function"==typeof this.config.html?this.config.html.call():this.config.html),"select"===this.config.type?this.renderSelect():"list"===this.config.type?(this.renderList(),this.renderButtons("multiselect"===this.config.listType,"boolean"==typeof this.config.cancelButton?this.config.cancelButton:"multiselect"!==this.config.listType)):"accordion"===this.config.type?(this.renderAccordion(),this.renderButtons(this.config.confirmButton,this.config.cancelButton)):"input"===this.config.type?(this.renderInput(),this.renderButtons("boolean"!=typeof this.config.confirmButton||this.config.confirmButton,"boolean"!=typeof this.config.cancelButton||this.config.cancelButton)):"range"===this.config.type?(this.renderRange(),this.renderButtons("boolean"!=typeof this.config.confirmButton||this.config.confirmButton,"boolean"!=typeof this.config.cancelButton||this.config.cancelButton)):this.renderButtons(this.config.confirmButton,this.config.cancelButton)},renderSelect:function(){"function"==typeof this.config.data&&(this.config.data=this.config.data()),this.config.data.forEach(function(t){var e=$('<a class="item button light-grey l">').html(t.html);e.data("callback",t.callback),e.appendTo(this.innerElement),e.on("vclick",function(t){var e=$(t.currentTarget).data("callback");"function"==typeof e&&e.apply(null),this.destroy(),t.preventDefault()}.bind(this)),t.focused===!0&&e.addClass("focus"),t.selected===!0&&e.addClass("selected"),"string"==typeof t.className&&(e.addClass(t.className),/(outline|negative|positive)/g.test(t.className)&&e.removeClass("light-grey"))}.bind(this)),this.domElement.attr("data-length",this.config.data.length)},renderList:function(){"function"==typeof this.config.data&&(this.config.data=this.config.data()),this.listElement=$('<div class="list">').appendTo(this.innerElement);var t=this.config.listType?this.config.listType:"select",e="select"===t||"multiselect"===t;this.domElement.attr("data-list-type",t),this.config.data.forEach(function(i){var n;n="string"==typeof i.href?$('<a class="list-item item" href="'+i.href+'"></a>'):$('<div class="list-item item"></div>'),n.html('<span class="list-item-title">'+(i.title?i.title:i.value)+"</span>"),e&&n.append('<span class="checkmark icon i-checkmark"></span>'),n.data({callback:i.callback,value:i.value}),n.appendTo(this.listElement),n.on("click",function(e){var n=$(e.currentTarget),s=n.data("callback"),o=n.data("value");"multiselect"===t&&(n.toggleClass("selected"),i.exclusive?(n.addClass("selected"),n.siblings().removeClass("selected")):n.siblings().filter(".exclusive").removeClass("selected")),"function"==typeof s&&s.apply(null,[o,n.hasClass("selected")]),"multiselect"!==t&&(this.confirmed.dispatch(o),this.destroy())}.bind(this)),"string"==typeof i.description&&(n.addClass("has-description"),n.append('<p class="list-item-description">'+i.description+"</p>")),"string"==typeof i.icon&&(n.wrapInner('<div class="list-item-content"></div>'),n.prepend('<span class="list-item-icon icon i-'+i.icon+'" style="'+(i.iconStyle||"")+'"></span>'),n.addClass("has-icon")),i.focused===!0&&n.addClass("focus"),i.selected===!0&&e&&n.addClass("selected"),i.exclusive===!0&&e&&n.addClass("exclusive"),"string"==typeof i.className&&n.addClass(i.className)}.bind(this))},renderAccordion:function(){this.accordionElement=$('<div class="accordion">').appendTo(this.innerElement),SL.util.skipCSSTransitions(this.accordionElement,1),this.config.data.items.forEach(function(t){var e=$('<div class="accordion-item">');e.attr("data-value",t.value).data({callback:t.callback}).html(['<div class="item-header">','<span class="title"></span>','<span class="expand-button checkmark-square"></span>','<span class="collapse-button icon i-x"></span>',"</div>",'<div class="item-content"></div>'].join("")),"string"==typeof t.collapseTooltip&&e.find(".collapse-button").attr("data-tooltip",t.collapseTooltip),e.find(".item-header .title").html(t.title||""),e.find(".item-header .title").before(t.beforeTitle||""),e.find(".item-header .title").after(t.afterTitle||""),e.appendTo(this.accordionElement),e.find(".item-header").on("vclick",function(t){var e=$(t.currentTarget).parent(),i=e.data("callback"),n=e.hasClass("selected");"function"==typeof i?i.apply(null,[!n])!==!1&&this.toggleAccordion(e.attr("data-value"),!n):this.toggleAccordion(e.attr("data-value"),!n),t.preventDefault()}.bind(this)),"function"==typeof t.content?e.find(".item-content").append(t.content()):e.find(".item-content").append(t.content),t.selected===!0&&e.addClass("selected"),"string"==typeof t.className&&e.addClass(t.className)}.bind(this))},toggleAccordion:function(t,e){this.accordionElement.find('[data-value="'+t+'"]').toggleClass("selected",e),this.domElement.toggleClass("accordion-open",this.accordionElement.find(".accordion-item.selected").length>0),this.layoutAccordion()},layoutAccordion:function(){var t=this.getPromptHeight();(!this.lastAccordionHeight||t<this.lastAccordionHeight||this.innerElement.offset().top+t>=window.innerHeight-this.config.windowSpacing)&&(this.lastAccordionHeight=t,this.layout())},renderInput:function(){if(this.config.data.multiline===!0){var t=this.config.data.cols||40,e=this.config.data.rows||8;this.inputElement=$('<textarea cols="'+t+'" rows="'+e+'" class="input-field">')}else this.inputElement=$('<input type="text" class="input-field">');"number"==typeof this.config.data.width&&(this.inputElement.css("width",this.config.data.width),this.titleElement&&this.titleElement.css("max-width",this.config.data.width),this.subtitleElement&&this.subtitleElement.css("max-width",this.config.data.width),this.bodyTextElement&&this.bodyTextElement.css("max-width",this.config.data.width)),this.config.data.value&&this.inputElement.val(this.config.data.value),this.config.data.readonly&&this.inputElement.attr("readonly","readonly"),this.config.data.placeholder&&this.inputElement.attr("placeholder",this.config.data.placeholder),this.config.data.maxlength&&this.inputElement.attr("maxlength",this.config.data.maxlength),this.inputWrapperElement=$('<div class="input-wrapper">').append(this.inputElement),this.inputWrapperElement.appendTo(this.innerElement),this.config.data.autoselect&&this.inputElement.select()},renderRange:function(){this.rangeInput=new SL.components.Range(this.config.data),this.rangeInput.appendTo(this.innerElement),"number"==typeof this.config.data.width&&(this.titleElement&&this.titleElement.css("max-width",this.config.data.width),this.subtitleElement&&this.subtitleElement.css("max-width",this.config.data.width))},renderButtons:function(t,e){var i=[];e&&this.config.optional&&this.config.cancelLabel&&i.push($('<button class="button l light-grey prompt-cancel">'+this.config.cancelLabel+"</button>")),t&&this.config.confirmLabel&&i.push($('<button class="button l prompt-confirm">'+this.config.confirmLabel+"</button>")),this.config.customFooterButtons&&this.config.customFooterButtons.length&&this.config.customFooterButtons.forEach(function(t){var e=$('<button class="button l '+(t.className||"")+'">'+t.label+"</button>");"function"==typeof t.callback&&e.on("vclick",t.callback),"string"==typeof t.tooltip&&e.attr("data-tooltip",t.tooltip),i.push(e)}),i.length&&(this.footerElement=$('<div class="footer"></div>').appendTo(this.innerElement),this.footerElement.append(i))},bind:function(){$(window).on("resize",this.asyncLayout),this.domElement.on("vmousedown",this.onBackgroundClicked),SL.keyboard.keydown(this.onDocumentKeydown),"hidden"!==$("html").css("overflow")&&$(window).on("scroll",this.layout),this.domElement.find(".prompt-cancel").on("vclick",this.onPromptCancelClicked),this.domElement.find(".prompt-confirm").on("vclick",this.onPromptConfirmClicked),this.inputElement&&this.inputElement.on("input",this.checkInputStatus)},unbind:function(){$(window).off("resize",this.asyncLayout),$(window).off("scroll",this.layout),this.domElement.off("vmousedown",this.onBackgroundClicked),SL.keyboard.release(this.onDocumentKeydown),this.domElement.find(".prompt-cancel").off("vclick",this.onPromptCancelClicked),this.domElement.find(".prompt-confirm").off("vclick",this.onPromptConfirmClicked),this.inputElement&&this.inputElement.off("input",this.checkInputStatus)},asyncLayout:function(){setTimeout(this.layout,1)},layout:function(){var t=$(window).width(),e=window.innerHeight,i="number"==typeof this.config.minWidth?this.config.minWidth:"",n="number"==typeof this.config.maxWidth?this.config.maxWidth:t-2*this.config.windowSpacing;this.innerElement.css({"min-width":i,"max-width":n,"max-height":this.getPromptMaxHeight()}),this.wrapperElement.css({left:"",top:"",transform:"",webkitTransform:""});var s=this.getPromptWidth(),o=this.getPromptHeight(),a=4,r=$(this.config.anchor);if(r.length){var l=r.offset(),d=15,c=this.config.alignment,h=$(window).scrollLeft(),u=$(window).scrollTop(),p=l.left-h,m=l.top-u;p+=this.config.offsetX,m+=this.config.offsetY;var f=r.outerWidth(),g=r.outerHeight(),v=s/2,b=o/2,S=10,y=S+a,E=!0;switch("auto"===c?c=l.top-(o+d+S)<u?"b":"t":"lr"===c&&(c=l.left-(s+d+S)<h?"r":"l"),this.domElement.attr("data-alignment",c),c){case"t":p+=(f-s)/2,m-=o+d;break;case"b":p+=(f-s)/2,m+=g+d;break;case"l":p-=s+d,m+=(g-o)/2;break;case"r":p+=f+d,m+=(g-o)/2}var T=m;switch(p=Math.max(Math.min(p,t-s-this.config.windowSpacing),this.config.windowSpacing),m=Math.max(Math.min(m,e-o-this.config.windowSpacing),this.config.windowSpacing),p=Math.round(p),m=Math.round(m),"b"===c&&m-T<-g-S?E=!1:"t"===c&&m-T>g+S&&(E=!1),c){case"t":v=l.left-p-h+f/2,v=Math.max(Math.min(v,s-y),y),b=o;break;case"b":v=l.left-p-h+f/2,v=Math.max(Math.min(v,s-y),y),b=-S;break;case"l":v=s,b=l.top-m-u+g/2,b=Math.max(Math.min(b,o-y),y);break;case"r":v=-S,b=l.top-m-u+g/2,b=Math.max(Math.min(b,o-y),y)}this.useTransformPositioning()?this.wrapperElement.css({webkitTransform:"translate("+p+"px,"+m+"px)",transform:"translate("+p+"px,"+m+"px)"}):this.wrapperElement.css({left:p,top:m}),this.arrowElement.css({left:v,top:b}).toggle(E)}else{var L=Math.round((t-s)/2),k=Math.round(.4*(e-o));this.useTransformPositioning()?this.wrapperElement.css({webkitTransform:"translate("+L+"px,"+k+"px)",transform:"translate("+L+"px,"+k+"px)"}):this.wrapperElement.css({left:L,top:k}),this.arrowElement.hide()}},getPromptHeight:function(){if("accordion"===this.config.type){var t=0;return this.accordionElement.find(".accordion-item").each(function(){var e=$(this),i=e.find(".item-header"),n=e.find(".item-content");t+=i.outerHeight()+parseInt(e.css("padding-top"),10)+parseInt(e.css("padding-bottom"),10),e.hasClass("selected")&&(t+=n.prop("scrollHeight")+parseInt(n.css("margin-top"),10)+parseInt(n.css("margin-bottom"),10))}),t}return this.innerElement.outerHeight()},getPromptWidth:function(){return this.innerElement.outerWidth()},getPromptMaxHeight:function(){return window.innerHeight-2*this.config.windowSpacing},useTransformPositioning:function(){return"accordion"===this.config.type},focus:function(t){var e=this.innerElement.find(".focus");if(e.length||(e=this.innerElement.find(".selected")),e.length){var i=t>0?e.next(".item"):e.prev(".item");i.length&&(e.removeClass("focus"),i.addClass("focus"))}else this.innerElement.find(".item").first().addClass("focus")},show:function(){var t=$(this.config.anchor);t.length&&t.addClass("focus"),$(this.config.hoverTarget).addClass(this.config.hoverClass),this.domElement.removeClass("visible").appendTo(document.body),setTimeout(function(){this.domElement.addClass("visible")}.bind(this),1),this.layout(),this.bind(),this.inputElement?(this.checkInputStatus(),this.inputElement.focus()):this.rangeInput&&this.rangeInput.focus()},hide:function(){var t=$(this.config.anchor);t.length&&t.removeClass("focus"),$(this.config.hoverTarget).removeClass(this.config.hoverClass),this.domElement.detach(),this.unbind()},showOverlay:function(t,e,i,n){return clearTimeout(this.overlayTimeout),this.overlay||(this.overlay=$('<div class="sl-prompt-overlay">')),this.overlay.appendTo(this.innerElement),this.overlay.html(i+"<h3>"+e+"</h3>"),this.overlay.attr("data-status",t||"neutral"),this.overlay.addClass("visible"),new Promise(function(t){n?this.overlayTimeout=setTimeout(function(){this.overlay.removeClass("visible"),t()}.bind(this),n):t()}.bind(this))},getValue:function(){var t=void 0;return"input"===this.config.type?t=this.inputElement.val():"range"===this.config.type?t=this.rangeInput.getValue():"list"===this.config.type&&"multiselect"===this.config.listType&&(t={},this.listElement.find(".item").each(function(){var e=$(this),i=e.data("value");i&&(t[i]=e.hasClass("selected"))})),t},getDOMElement:function(){return this.domElement},cancel:function(){if("input"===this.config.type&&this.config.data.confirmBeforeDiscard){var t=this.config.data.value||"",e=this.getValue()||"";e!==t?this.promptUnsavedChanges():(this.canceled.dispatch(this.getValue()),this.destroy())}else this.canceled.dispatch(this.getValue()),this.destroy()},promptUnsavedChanges:function(t){t=$.extend({title:"There are unsaved changes. Do you want to save?"},t),SL.prompt({title:t.title,type:"select",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Discard</h3>",selected:!1,className:"negative",callback:function(){this.canceled.dispatch(this.getValue()),this.destroy()}.bind(this)},{html:"<h3>Save changes</h3>",selected:!0,className:"positive",callback:function(){this.confirm()}.bind(this)}]})},confirm:function(){this.confirmed.dispatch(this.getValue()),this.config.destroyAfterConfirm&&this.destroy()},checkInputStatus:function(){if(this.config.data.maxlength&&!this.config.data.maxlengthHidden){var t=this.inputWrapperElement.find(".input-status");0===t.length&&(t=$('<div class="input-status">').appendTo(this.inputWrapperElement));var e=this.inputElement.val().length,i=this.config.data.maxlength;t.text(e+"/"+i),t.toggleClass("negative",e>.95*i),this.config.data.multiline||this.inputElement.css("padding-right",t.outerWidth()+5)}},getInputElement:function(){return this.inputElement},destroy:function(){if(this.destroyed){this.destroyed.dispatch(),this.destroyed.dispose(),this.destroyed=null;var t=$(this.config.anchor);t.length&&t.removeClass("focus"),$(this.config.hoverTarget).removeClass(this.config.hoverClass),this.domElement.remove(),this.unbind(),this.confirmed.dispose(),this.canceled.dispose()}},onBackgroundClicked:function(t){this.config.optional&&$(t.target).is(this.domElement)&&(this.cancel(),t.preventDefault())},onPromptCancelClicked:function(t){this.cancel(),t.preventDefault()},onPromptConfirmClicked:function(t){this.confirm(),t.preventDefault()},onDocumentKeydown:function(t){if(27===t.keyCode)return this.config.optional&&this.cancel(),t.preventDefault(),!1;if("select"===this.config.type||"list"===this.config.type)if(13===t.keyCode||32===t.keyCode){var e=this.innerElement.find(".focus");0===e.length&&(e=this.innerElement.find(".selected")),e.length&&(e.trigger("click"),t.preventDefault())}else 37===t.keyCode||38===t.keyCode?(this.focus(-1),t.preventDefault()):39===t.keyCode||40===t.keyCode?(this.focus(1),t.preventDefault()):9===t.keyCode&&t.shiftKey?(this.focus(-1),t.preventDefault()):9===t.keyCode&&(this.focus(1),t.preventDefault());if("accordion"===this.config.type){var i=document.activeElement&&document.activeElement.tagName&&/input|textarea|select/i.test(document.activeElement.tagName),n=t.altKey||t.ctrlKey||t.metaKey;if(i===!1&&n===!1)return t.preventDefault(),!1}if("input"===this.config.type||"form"===this.config.type||"range"===this.config.type){var s=/textarea/i.test(t.target.nodeName);13!==t.keyCode||s&&!t.metaKey&&!t.ctrlKey||this.onPromptConfirmClicked(t)}return"custom"===this.config.type&&this.config.confirmOnEnter&&13===t.keyCode&&this.onPromptConfirmClicked(t),!0}}),SL.prompt=function(t){var e=new SL.components.Prompt(t);return e.show(),e},SL.prompt.isOpen=function(){return document.querySelectorAll(".sl-prompt.visible").length>0},SL.promptOnHover=function(t,e,i){if("pointerEvents"in document.documentElement.style&&!SL.util.device.IS_PHONE&&!SL.util.device.IS_TABLET){var n,i=i||SL.components.Prompt;e.closeOnClickOutside=!1,e.pointerEvents="none",t.on("vmouseover",function(){n=new i(e),n.show(),n.destroyed.add(function(){n=null})}),t.on("vmouseout vclick",function(){n&&(n.destroy(),n=null)})}},SL("components.prompts").AutoAnimate=SL.components.Prompt.extend({init:function(t){this.config=t,this.afterSettingsChanged=this.afterSettingsChanged.bind(this),this._super($.extend({type:"form",className:"sl-auto-animate-prompt",confirmLabel:"Save"+SL.util.getKeyboardShortcutName("Enter",{meta:!0,casesensitive:!0,span:!0}),confirmButton:!0,cancelButton:!0,
customFooterButtons:[{label:"?",className:"left-align light-grey help-button"},{label:"Disable Auto-Animate",className:"left-align light-grey disable-button"}],maxWidth:500,html:this.renderSettings()},t)),this.initialState=this.getState(),this.setPreviewStep(0),this.findAdjacentAutoAnimateSlides(),this.updatePreviewLabel(),this.updateApplyToAll(),SL.editor.controllers.Blocks.blur()},findAdjacentAutoAnimateSlides:function(){var t=this.getState(),e=function(e){return t.duration==this.readDuration(e)&&t.easing==this.readEasing(e)&&t.unmatched==this.readUnmatched(e)};this.adjacentSlidesWithSameSettings=[];var i,n=$(this.config.slide).nextUntil(":not([data-auto-animate])").toArray();for(i=0;i<n.length&&e.call(this,n[i]);i++)this.adjacentSlidesWithSameSettings.push(n[i]);var s=$(this.config.slide).prevUntil(":not([data-auto-animate])").toArray();for(i=0;i<s.length&&e.call(this,s[i]);i++)this.adjacentSlidesWithSameSettings.push(s[i])},renderSettings:function(){this.bodyElement=$('<div class="settings-body"></div>'),this.formElement=$('<div class="sl-form">').appendTo(this.bodyElement),this.renderTitle().appendTo(this.formElement),this.renderPreview().appendTo(this.formElement);var t=$('<div class="unit-row"></div>').appendTo(this.formElement);return this.renderDuration().appendTo(t),this.renderUnmatched().appendTo(t),this.renderEasing().appendTo(this.formElement),this.renderApplyToAll().appendTo(this.formElement),this.bodyElement},renderTitle:function(){var t=$(['<div class="unit auto-animate-status">','<h4 class="form-label">Auto-Animate: Enabled</h4>','<h6 class="beta-label">Beta</h6>','<p class="unit-description">Automatically animate matching elements between two slides. <strong>'+SL.keyboard.getEditorShortcut("EDITOR_PREVIEW").shortcut+" to preview.</strong></p>","</div>"].join(""));return t},renderPreview:function(){var t=$('\t\t\t<div class="animation-preview">\t\t\t\t<div class="animation-preview-inner"></div>\t\t\t\t<span class="animation-preview-label"></span>\t\t\t\t<ul class="animation-preview-pagination"></ul>\t\t\t</div>\t\t');this.previewLabel=t.find(".animation-preview-label");var e=t.find(".animation-preview-inner"),i=$('<div class="animation-preview-block" style="top: 50%; left: 50%; margin: -20px 0 0 -20px; width: 40px; height: 40px; border-radius: 40px; background: rgb(100, 100, 100);"></div>').appendTo(e).get(0),n=$('<div class="animation-preview-block" style="top: 50%; left: 50%; margin: -20px 0 0 -20px; width: 40px; height: 40px; border-radius: 40px; background: rgb(100, 100, 100);"></div>').appendTo(e).get(0),s=$('<div class="animation-preview-block" style="top: 50%; left: 50%; margin: -20px 0 0 -20px; width: 40px; height: 40px; border-radius: 40px; background: rgb(100, 100, 100);"></div>').appendTo(e).get(0),o=$('<p class="animation-preview-block unmatched" style="font-size: 16px; width: 100%; margin: 0; text-align: center; top: 68%; color: #999;">This is an example slide transition</p>').appendTo(e).get(0);return this.previewSteps=[function(){o.classList.remove("unmatched-visible"),i.style.transform="translate(-80%, 0%) scale(1.6)",n.style.transform="translate(0%, 0%) scale(1.6)",s.style.transform="translate(80%, 0%) scale(1.6)",i.style.background="rgb(190, 190, 190)",n.style.background="rgb(130, 130, 130)"},function(){o.classList.add("unmatched-visible"),i.style.transform="translate(-400%, -25%) scale(1.6)",n.style.transform="translate(0%, -45%) scale(1.6)",s.style.transform="translate(400%, -25%) scale(1.6)",i.style.background="rgb(100, 100, 100)",n.style.background="rgb(100, 100, 100)"},function(){o.classList.remove("unmatched-visible"),i.style.transform="translate(-200%, 0%)",n.style.transform="translate(0%, 0%)",s.style.transform="translate(200%, 0%)",i.style.background="rgb(100, 100, 100)",n.style.background="rgb(100, 100, 100)"}],t.find(".animation-preview-pagination").append(this.previewSteps.map(function(){return"<li></li>"}).join("")),t.find(".animation-preview-pagination li").on("vclick",function(t){this.setPreviewStep($(t.currentTarget).index())}.bind(this)),t},setPreviewStep:function(t){this.currentPreviewStep=t;var e=this.getState(),i="number"!=typeof e.duration||isNaN(e.duration)?3e3:1e3*(e.duration+2);this.bodyElement.find(".animation-preview-block.unmatched").css("transition",e.unmatched===!0?"":"none"),this.bodyElement.find(".animation-preview-inner").css("transition",this.getCSSTransition()),this.bodyElement.find(".animation-preview-pagination li").removeClass("selected"),this.bodyElement.find(".animation-preview-pagination li:eq("+t+")").addClass("selected"),this.previewSteps[t](),clearInterval(this.previewTimeout),this.previewTimeout=setTimeout(this.setPreviewStep.bind(this,(t+1)%this.previewSteps.length),i)},nextPreviewStep:function(){SL.util.skipCSSTransitions(this.bodyElement.find(".animation-preview"),0,function(){this.setPreviewStep((this.currentPreviewStep+1)%this.previewSteps.length)}.bind(this))},renderDuration:function(){var t=$(['<div class="unit duration">','<h4 class="form-label">Duration</h4>','<p class="unit-description">Animation duration in seconds.</p>',"</div>"].join(""));return this.durationInput=new SL.components.Range({minValue:SL.config.AUTO_ANIMATE_DURATION_MIN/1e3,maxValue:SL.config.AUTO_ANIMATE_DURATION_MAX/1e3,decimals:1,stepSize:.1,unit:"s",width:"100%",value:this.readDuration()}),this.durationInput.changeEnded.add(this.afterSettingsChanged),this.durationInput.appendTo(t),t},renderEasing:function(){var t=$('\t\t\t<div class="unit">\t\t\t\t<h4 class="form-label">Easing</h4>\t\t\t\t<p class="unit-description">The type of easing function to use for this animation.</p>\t\t\t</div>\t\t');return this.easingList=new SL.components.EasingList({thumbTransitionSeconds:function(){return this.getState().duration}.bind(this)}),this.easingList.setValue(this.readEasing()),this.easingList.appendTo(t),this.easingList.selectionChanged.add(this.afterSettingsChanged),t},renderUnmatched:function(){var t=$(['<div class="unit">','<h4 class="form-label">Unmatched elements</h4>','<p class="unit-description">Fade in unmatched elements.</p>','<div class="unit sl-checkbox outline">','<input id="fade-input" class="fade-input" type="checkbox" />','<label for="fade-input">Fade in</label>',"</div>","</div>"].join(""));return this.fadeInput=t.find(".fade-input"),this.fadeInput.get(0).checked=this.readUnmatched(),t},renderApplyToAll:function(){var t=$(['<div class="unit">','<div class="unit sl-checkbox outline">','<input id="apply-to-all-input" class="apply-to-all-input" type="checkbox" />','<label for="apply-to-all-input" class="apply-to-all-label"></label>',"</div>","</div>"].join("")),e=SL.components.prompts.AutoAnimate.LAST_APPLY_TO_ALL_SETTING;return"boolean"!=typeof e&&(e=!0),this.applyToAllUnit=t,this.applyToAllLabel=t.find(".apply-to-all-label"),this.applyToAllInput=t.find(".apply-to-all-input"),this.applyToAllInput.get(0).checked=e,t},bind:function(){this._super.apply(this,arguments),this.domElement.find(".help-button").on("vclick",this.onHelpClicked.bind(this)),this.domElement.find(".disable-button").on("vclick",this.onDisableAutoAnimate.bind(this));var t=this.domElement.find(".help-button");SL.promptOnHover(t,SL.editor.controllers.AutoAnimate.getAutoAnimateHelpPromptOptions({anchor:t,title:"How to Add an Animation"}),SL.components.prompts.PreviewMedia)},cancel:function(){JSON.stringify(this.initialState)!==JSON.stringify(this.getState())?this.promptUnsavedChanges({title:"There are unsaved Auto-Animate changes. Save them?"}):this._super.apply(this,arguments)},confirm:function(){var t=this.getState(),e=[this.config.slide],i=this.applyToAllInput.get(0).checked;SL.components.prompts.AutoAnimate.LAST_APPLY_TO_ALL_SETTING=i,i===!0&&(e=e.concat(this.adjacentSlidesWithSameSettings)),e.forEach(function(e){this.applySettingsToSlides(e,t)},this),Reveal.sync(),this._super.apply(this,arguments)},applySettingsToSlides:function(t,e){this.durationInput&&(e.duration&&e.duration!==SL.config.AUTO_ANIMATE_DURATION_DEFAULT/1e3?t.setAttribute("data-auto-animate-duration",e.duration):t.removeAttribute("data-auto-animate-duration")),this.easingList&&(e.easing&&e.easing!==SL.config.AUTO_ANIMATE_EASING_DEFAULT?t.setAttribute("data-auto-animate-easing",e.easing):t.removeAttribute("data-auto-animate-easing")),this.fadeInput&&(e.unmatched!==SL.config.AUTO_ANIMATE_UNMATCHED_DEFAULT?t.setAttribute("data-auto-animate-unmatched",e.unmatched):t.removeAttribute("data-auto-animate-unmatched"))},updatePreviewLabel:function(){var t=this.getState();this.previewLabel.text(t.duration+"s "+this.easingList.getTitleForCurrentValue())},updateApplyToAll:function(){this.adjacentSlidesWithSameSettings.length>0?this.applyToAllLabel.html("Apply changes to <strong>"+this.adjacentSlidesWithSameSettings.length+"</strong> adjacent auto-animate slides"):this.applyToAllUnit.hide()},afterSettingsChanged:function(){this.updatePreviewLabel(),this.nextPreviewStep()},getState:function(){return{duration:parseFloat(this.durationInput.getValue()),easing:this.easingList.getValue(),unmatched:this.fadeInput.get(0).checked===!0}},readDuration:function(t){t=t||this.config.slide;var e;return t.hasAttribute("data-auto-animate-duration")&&(e=t.getAttribute("data-auto-animate-duration")),"undefined"!=typeof e&&(e=parseFloat(e)),isNaN(e)?SL.config.AUTO_ANIMATE_DURATION_DEFAULT/1e3:e},readEasing:function(t){t=t||this.config.slide;var e;return t.hasAttribute("data-auto-animate-easing")&&(e=t.getAttribute("data-auto-animate-easing")),e||SL.config.AUTO_ANIMATE_EASING_DEFAULT},readUnmatched:function(t){t=t||this.config.slide;var e;return t.hasAttribute("data-auto-animate-unmatched")&&(e=t.getAttribute("data-auto-animate-unmatched"),e="false"!==e),"undefined"!=typeof e?e:SL.config.AUTO_ANIMATE_UNMATCHED_DEFAULT},destroy:function(){this._super.apply(this,arguments),this.durationInput&&this.durationInput.destroy(),clearInterval(this.previewTimeout)},getCSSTransition:function(){var t=this.getState();return"all "+t.duration+"s "+t.easing},onDisableAutoAnimate:function(){SL.editor.controllers.AutoAnimate.disable(this.config.slide),this.destroy()},onHelpClicked:function(){window.open("https://help.slides.com/knowledgebase/articles/1937638","_blank")},onDocumentKeydown:function(t){var e=this._super.apply(this,arguments);return e!==!1&&((t.metaKey||t.ctrlKey)&&70===t.keyCode&&(this.confirm(),SL.editor.controllers.Mode.toggle("preview"),SL.editor.controllers.Mode.get("preview").deactivated.addOnce(function(){Reveal.getCurrentSlide().hasAttribute("data-auto-animate")&&SL.view.slideMenu.triggerAutoAnimate()}),t.preventDefault()),!0)}}),SL("components.prompts").DeckTiming=SL.components.Prompt.extend({init:function(t){this.config=t,this._super($.extend({type:"form",className:"sl-deck-timing-prompt",confirmLabel:"Save",confirmButton:!0,cancelButton:!0,customFooterButtons:[{label:"Reset",className:"left-align light-grey reset-button",callback:this.onResetClicked.bind(this)}],html:this.renderContent.bind(this)},t)),this.initialValue=this.getValue(),this.syncResetButton()},renderContent:function(){return this.formElement=$('<div class="sl-form">'),this.renderTimeLimit().appendTo(this.formElement),this.formElement},renderTimeLimit:function(){this.syncTimeLimitSelection=$.throttle(this.syncTimeLimitSelection,100);var t=$(['<div class="unit text">','<h4 class="form-label">Time Limit</h4>','<p class="unit-description">Specify how many minutes you have to give this presentation to see a countdown. Leave empty for a count up timer.</p>','<div class="suffixed-input">','<input class="time-limit" type="number" placeholder="">','<div class="suffix text-faded"><span>min</span></div>',"</div>",'<div class="input-field-tray input-field-tray-presets">',"</div>","</div>"].join(""));this.timeLimitPresets=t.find(".input-field-tray-presets");var e=SL.config.DECK_TIME_LIMIT.map(function(t){return{label:t+"min",value:t}});return this.timeLimitPresets.append(e.map(function(t){return'<div class="input-field-tray-preset" data-duration="'+t.value+'">'+t.label+"</div>"})),this.timeLimitPresets.on("vclick",".input-field-tray-preset",function(t){this.setTimeLimitValue(t.currentTarget.getAttribute("data-duration"))}.bind(this)),this.timeLimitInput=t.find(".time-limit"),this.timeLimitInput.on("input",this.syncTimeLimitSelection.bind(this)),this.timeLimitInput.on("blur",function(){this.setTimeLimitValue(this.timeLimitInput.val().trim())}.bind(this)),"number"==typeof SL.current_deck.get("time_limit")&&SL.current_deck.get("time_limit")>0&&this.setTimeLimitValue(SL.current_deck.get("time_limit")),this.syncTimeLimitSelection(),t},show:function(){this._super.apply(this,arguments),this.timeLimitInput.focus()},cancel:function(){JSON.stringify(this.initialValue)!==JSON.stringify(this.getValue())?this.promptUnsavedChanges():this._super.apply(this,arguments)},confirm:function(){var t=this.getValue();this.timeLimitInput&&(SL.current_deck.set("time_limit",t.timeLimit),SL.current_deck.save(["time_limit"])),this._super.apply(this,arguments)},setTimeLimitValue:function(t){this.timeLimitInput.val(t),this.syncTimeLimitSelection(),this.syncResetButton()},getValue:function(){var t=parseInt(this.timeLimitInput.val().trim(),10);return t=Math.max(t,0),t=Math.min(t,1440),isNaN(t)&&(t=0),{timeLimit:t}},syncTimeLimitSelection:function(){var t=parseInt(this.timeLimitInput.val().trim(),10);this.timeLimitPresets.find(".input-field-tray-preset.selected").removeClass("selected"),t&&this.timeLimitPresets.find('.input-field-tray-preset[data-duration="'+t+'"]').addClass("selected")},syncResetButton:function(){this.domElement.find(".reset-button").toggle(0!==this.getValue().timeLimit)},onResetClicked:function(){this.setTimeLimitValue("")},destroy:function(){this._super.apply(this,arguments)}}),SL("components.prompts").DeckView=SL.components.Prompt.extend({init:function(t){var e=t.deckModel||SL.current_deck,i=e.user.get("username"),n=e.get("slug");this._super($.extend({type:"list",title:"Open deck to...",className:"sl-deck-view-prompt",data:this.getOptionList.bind(this),cancelButton:!1,listType:"links",deckModel:e,presentURL:SL.routes.DECK_LIVE(i,n),editorURL:SL.routes.DECK_EDIT(i,n),kioskURL:SL.routes.DECK_KIOSK(i,n),deckURL:SL.routes.DECK(i,n)},t))},getOptionList:function(){var t=[],e=SL.current_user&&SL.current_user.get("id")===this.config.deckModel.get("user").id;return this.config.editorURL&&t.push({title:"Edit",icon:"pen-alt2",description:"Make changes to the deck.",href:this.config.editorURL}),this.config.presentURL&&e&&t.push({title:"Present",icon:"play",iconStyle:"position: relative; left: 2px;",description:"Live present with Speaker View.",href:this.config.presentURL}),this.config.deckURL&&t.push({title:"View",icon:"eye",description:"Open and browse your deck.",href:this.config.deckURL}),this.config.kioskURL&&t.push({title:"Autoplay",icon:"live-tv",iconStyle:"position: relative; top: -2px;",description:"Loop your deck in the Kiosk Mode.",href:this.config.kioskURL}),t}}),SL("components.prompts").DeckVisibility=SL.components.Prompt.extend({init:function(t,e){this.deckModel=t,this.visibilitySelected=new signals.Signal,this._super($.extend({type:"select",className:"sl-visibility-prompt",data:this.getVisibilityOptions(),persistVisibility:!0},e))},getVisibilityOptions:function(){var t=[],e=SL.current_user.isEnterprise(),i=!SL.current_user.isEnterprise()||SL.current_team.allowPublicDecks();return t.push({html:SL.locale.get("DECK_VISIBILITY_CHANGE_SELF"),selected:this.deckModel.get("visibility")===SL.models.Deck.VISIBILITY_SELF,callback:this.selectVisibility.bind(this,SL.models.Deck.VISIBILITY_SELF)}),e&&t.push({html:SL.locale.get("DECK_VISIBILITY_CHANGE_TEAM"),selected:this.deckModel.get("visibility")===SL.models.Deck.VISIBILITY_TEAM,className:"divider",callback:this.selectVisibility.bind(this,SL.models.Deck.VISIBILITY_TEAM)}),i?t.push({html:SL.locale.get("DECK_VISIBILITY_CHANGE_ALL"),selected:this.deckModel.get("visibility")===SL.models.Deck.VISIBILITY_ALL,callback:this.selectVisibility.bind(this,SL.models.Deck.VISIBILITY_ALL)}):t.push({html:SL.locale.get("DECK_VISIBILITY_SHARE_LINK"),callback:function(){SL.popup.open(SL.components.decksharer.DeckSharer,{deck:this.deckModel})}.bind(this)}),t},selectVisibility:function(t){if(this.config.persistVisibility){var e=$.ajax({type:"POST",url:SL.endpoints.PUBLISH_DECK(this.deckModel.get("id")),context:this,data:{visibility:t}}).done(function(t){t.deck.visibility===SL.models.Deck.VISIBILITY_SELF?SL.notify(SL.locale.get("DECK_VISIBILITY_CHANGED_SELF")):t.deck.visibility===SL.models.Deck.VISIBILITY_TEAM?SL.notify(SL.locale.get("DECK_VISIBILITY_CHANGED_TEAM")):t.deck.visibility===SL.models.Deck.VISIBILITY_ALL&&SL.notify(SL.locale.get("DECK_VISIBILITY_CHANGED_ALL")),"string"==typeof t.deck.slug&&this.deckModel.set("slug",t.deck.slug),"string"==typeof t.deck.visibility&&this.deckModel.set("visibility",t.deck.visibility)}).fail(function(){SL.notify(SL.locale.get("DECK_VISIBILITY_CHANGED_ERROR"),"negative")});this.visibilitySelected.dispatch(t,e)}else this.visibilitySelected.dispatch(t)},destroy:function(){this.visibilitySelected.dispose(),this._super.apply(this,arguments)}}),SL("components.prompts").Notes=SL.components.Prompt.extend({init:function(t){var e=[];SL.editor.controllers.Capabilities.isTouchEditor()||e.push({label:'Dock notes <span class="dock-icon"></span>',className:"left-align light-grey dock-button",callback:this.onDockNotesClicked.bind(this)}),this._super($.extend(!0,{type:"input",title:"Speaker Notes",className:"sl-notes-prompt",subtitle:SL.current_deck.get("share_notes")===!0?SL.locale.get("NOTES_PUBLIC"):SL.locale.get("NOTES_PRIVATE"),confirmLabel:"Save"+SL.util.getKeyboardShortcutName("Enter",{meta:!0,casesensitive:!0,span:!0}),confirmButton:!0,cancelButton:!0,customFooterButtons:e,data:{placeholder:"Enter notes in plain text...",multiline:!0,cols:55,rows:16,maxlength:SL.config.SPEAKER_NOTES_MAXLENGTH,maxlengthHidden:!0,confirmBeforeDiscard:!0}},t))},onDockNotesClicked:function(){this.confirm(),SL.current_user.settings.set("editor_fixed_notes",!0),SL.current_user.settings.save(["editor_fixed_notes"])}}),SL("components.prompts").PreviewMedia=SL.components.Prompt.extend({init:function(t){this._super($.extend({type:"custom",className:"sl-preview-media-prompt",html:this.renderPreview(),destroyAfterConfirm:!0,mediaType:"image",mediaURL:null,mediaWidth:null,mediaHeight:null,mediaTiming:null},t)),isNaN(this.config.mediaWidth)&&(this.config.mediaWidth=null),isNaN(this.config.mediaHeight)&&(this.config.mediaHeight=null)},renderPreview:function(){return this.previewElement=$('<div class="preview-element"></div>'),this.previewElement},show:function(){this._super.apply(this,arguments),this.hasLoadedMedia||(null!==this.config.mediaWidth&&null!==this.config.mediaHeight||this.previewElement.addClass("unknown-size"),this.hasLoadedMedia=!0,this.load())},layout:function(){var t=this.config.mediaWidth,e=this.config.mediaHeight;if(this.previewElement.hasClass("loaded-media")&&(t=this.mediaElement.prop("naturalWidth")||this.mediaElement.prop("videoWidth"),e=this.mediaElement.prop("naturalHeight")||this.mediaElement.prop("videoHeight")),t&&e){var i=Math.round(Math.min(.8*$(window).width(),.5*window.innerHeight)),n=t/e;this.previewElement.css({width:Math.min(i,t),height:Math.min(i/n,e)})}else this.previewElement.css({width:250,height:175});this._super.apply(this,arguments)},load:function(){this.mediaPreloader=$(['<div class="media-preloader">','<div class="spinner centered" data-spinner-color="#333">',"</div>","</div>"].join("")).appendTo(this.previewElement),SL.util.html.generateSpinners(),"image"===this.config.mediaType?this.loadImage():"video"===this.config.mediaType?this.loadVideo():SL.notify('Unable to preview media of type "'+this.config.mediaType+'"'),this.layout()},loadImage:function(){this.mediaElement=$("<img>"),this.mediaElement.appendTo(this.previewElement),this.mediaElement.on("load",this.onMediaLoaded.bind(this)),this.mediaElement.on("error",this.onMediaLoadError.bind(this)),this.mediaElement.attr("src",this.config.mediaURL)},loadVideo:function(){this.mediaElement=$("<video muted loop>"),this.mediaElement.appendTo(this.previewElement),this.mediaElement.on("canplay",this.onMediaLoaded.bind(this)),this.mediaElement.on("error",this.onMediaLoadError.bind(this)),this.mediaElement.attr("src",this.config.mediaURL+(this.config.mediaTiming||""))},onMediaLoaded:function(){this.previewElement.addClass("loaded-media"),this.mediaElement.is("video")&&this.mediaElement.get(0).play(),this.mediaPreloader.remove(),this.layout()},onMediaLoadError:function(){this.mediaPreloader.remove(),SL.notify("Unable to load preview"),this.destroy()},destroy:function(){this.mediaElement&&(this.mediaElement.off(),this.mediaElement.attr("src",""),this.mediaElement.remove()),this._super.apply(this,arguments)}}),SL("components.prompts").SlideBackground=SL.components.Prompt.extend({init:function(t){this.config=t;var e=[];e.push(this.createColorOption()),e.push(this.createImageOption()),(SL.editor.controllers.Capabilities.canUploadVideo()||this.config.slide.hasAttribute("data-background-video"))&&e.push(this.createVideoOption()),e.push(this.createIframeOption()),this._super($.extend({type:"accordion",className:"sl-slide-background-prompt",overlayOpacity:.2,data:{items:e}},t))},show:function(){this._super.apply(this,arguments),this.checkVideoProcessingStatus(),this.syncColor(),this.syncImage(),this.syncVideo(),this.syncIframe()},removeBackgroundMedia:function(t){this.detachMediaModels(),SL.util.deck.removeSlideBackground(this.config.slide,t),Reveal.syncSlide(this.config.slide),this.syncImage(),this.syncVideo(),this.syncIframe()},createColorOption:function(){this.colorElement=$('<div class="background-color"></div>'),this.hasSelectedColor=this.config.slide.hasAttribute("data-background-color");var t={anchor:this.colorElement,container:this.colorElement,alpha:!1,inline:!0,changeCallback:this.setColor.bind(this),resizedCallback:this.layoutAccordion.bind(this)};return SL.view.colorpicker.show(t),{value:"background-color",title:"Color",beforeTitle:'<span class="icon i-droplet"></span>',collapseTooltip:"Remove background color",content:this.colorElement,callback:this.onColorClicked.bind(this)}},syncColor:function(){this.config.slide.hasAttribute("data-background-color")?(SL.view.colorpicker.setColor(this.config.slide.getAttribute("data-background-color")),this.toggleAccordion("background-color",!0)):(SL.view.colorpicker.setColor(null),this.toggleAccordion("background-color",!1))},setColor:function(t){this.config.slide.setAttribute("data-background-color",t),Reveal.syncSlide(this.config.slide),SL.editor.controllers.Contrast.sync(),this.hasSelectedColor=!0},clearColor:function(){this.config.slide.removeAttribute("data-background-color"),Reveal.syncSlide(this.config.slide),SL.editor.controllers.Contrast.sync()},onColorClicked:function(t){return t?(this.hasSelectedColor&&this.setColor(SL.view.colorpicker.getColor()),this.toggleAccordion("background-color",!0)):(this.clearColor(),this.syncColor()),SL.analytics.trackEditor("Toggle background color menu"),!1},createImageOption:function(){return this.imageElement=$('<div class="background-image"></div>'),this.onImageUploadSuccess=this.onImageUploadSuccess.bind(this),this.onImageUploadError=this.onImageUploadError.bind(this),{value:"background-image",title:"Image",beforeTitle:'<span class="icon i-picture"></span>',afterTitle:this.imageExternalURL,collapseTooltip:"Remove background image",content:this.imageElement,callback:this.onImageClicked.bind(this)}},syncImage:function(){this.imageElement.empty();var t=this.config.slide.getAttribute("data-background-image");"string"==typeof t&&t.length?(this.renderImageUploadedState(),this.toggleAccordion("background-image",!0)):this.imageModel?(this.renderImageUploadingState(),this.toggleAccordion("background-image",!0)):this.toggleAccordion("background-image",!1)},renderImageUploadingState:function(){var t=$('<div class="upload-progress"></div>').appendTo(this.imageElement);t.append('<span class="spinner" data-spinner-color="#444"></span>'),t.append('<span class="label">Uploading...</span>'),SL.util.html.generateSpinners()},renderImageUploadedState:function(){this.imageElement.append(['<div class="image-options">','<div class="media-thumbnail clickable" data-tooltip="Click to replace">','<div class="media-thumbnail-inner" style="background-image: url(\''+this.config.slide.getAttribute("data-background-image")+"')\"></div>","</div>",'<select class="sl-select image-size-input">','<option value="cover">Cover</option>','<option value="contain">Contain</option>','<option value="initial">Original</option>',"</select>",'<select class="sl-select image-position-input">','<option value="0% 0%">Top Left</option>','<option value="50% 0%">Top</option>','<option value="100% 0%">Top Right</option>','<option value="50% 50%">Center</option>','<option value="0% 100%">Bottom Left</option>','<option value="50% 100%">Bottom</option>','<option value="100% 100%">Bottom Right</option>',"</select>",'<div class="media-opacity-wrapper"></div>',"</div>"].join("")),this.imageElement.find(".media-thumbnail").on("vclick",this.browseForImage.bind(this));var t=(this.config.slide.getAttribute("data-background-position"),this.imageElement.find(".image-size-input"));t.val(this.config.slide.getAttribute("data-background-size")||SL.config.DEFAULT_SLIDE_IMAGE_BACKGROUND_SIZE),t.on("change",function(){var e=t.val();e!==SL.config.DEFAULT_SLIDE_IMAGE_BACKGROUND_SIZE?this.config.slide.setAttribute("data-background-size",e):this.config.slide.removeAttribute("data-background-size"),Reveal.syncSlide(this.config.slide),this.refreshImageThumbnail()}.bind(this));var e=this.imageElement.find(".image-position-input");e.val(this.config.slide.getAttribute("data-background-position")||SL.config.DEFAULT_SLIDE_IMAGE_BACKGROUND_POSITION),e.on("change",function(){var t=e.val();t!==SL.config.DEFAULT_SLIDE_IMAGE_BACKGROUND_POSITION?this.config.slide.setAttribute("data-background-position",t):this.config.slide.removeAttribute("data-background-position"),Reveal.syncSlide(this.config.slide),this.refreshImageThumbnail()}.bind(this)),this.renderOpacityRange().appendTo(this.imageElement.find(".media-opacity-wrapper")),this.refreshImageThumbnail()},refreshImageThumbnail:function(){var t=document.querySelector(".reveal").getBoundingClientRect(),e=t.width/t.height,i=this.imageElement.find(".media-thumbnail-inner"),n=Math.min(i.width()/e,280);i.css({height:n,"background-size":this.imageElement.find(".image-size-input").val(),"background-position":this.imageElement.find(".image-position-input").val()})},onImageClicked:function(t){return t?this.browseForImage():this.removeBackgroundMedia(),SL.analytics.trackEditor("Toggle background image menu"),!1},browseForImage:function(){var t=SL.popup.open(SL.components.medialibrary.MediaLibrary,{select:SL.models.Media.IMAGE,selectExternal:!0,selectExternalValue:this.config.slide.getAttribute("data-background-image")||""});t.selected.addOnce(function(t){this.removeBackgroundMedia(["size","position","opacity"]),this.imageModel=t,this.syncImage(),t.isUploaded()?this.onImageUploadSuccess():(t.uploadCompleted.add(this.onImageUploadSuccess),t.uploadFailed.add(this.onImageUploadError))}.bind(this)),t.selectedExternal.addOnce(function(t){this.removeBackgroundMedia(["size","position","opacity"]),this.config.slide.setAttribute("data-background-image",t),this.syncImage(),Reveal.syncSlide(this.config.slide)}.bind(this))},onImageUploadSuccess:function(){var t=this.imageModel.get("url");this.config.slide.setAttribute("data-background-image",t),Reveal.syncSlide(this.config.slide),SL.util.color.getImageColor(t).then(function(t){this.config.slide.hasAttribute("data-background-image")&&t.a>.95&&this.config.slide.setAttribute("data-background-color","rgb("+t.r+","+t.g+","+t.b+")"),Reveal.syncSlide(this.config.slide),this.syncColor()}.bind(this),function(){}),this.imageModel=null,this.syncImage()},onImageUploadError:function(){this.imageModel=null,this.syncImage()},createVideoOption:function(){return this.videoElement=$('<div class="background-video"></div>'),this.onVideoUploadSuccess=this.onVideoUploadSuccess.bind(this),this.onVideoUploadError=this.onVideoUploadError.bind(this),this.onVideoProcessingCompleted=this.onVideoProcessingCompleted.bind(this),this.onVideoProcessingFailed=this.onVideoProcessingFailed.bind(this),{value:"background-video",title:"Video",beforeTitle:'<span class="icon i-video-camera"></span>',afterTitle:this.videoExternalURL,collapseTooltip:"Remove background video",content:this.videoElement,callback:this.onVideoClicked.bind(this)}},checkVideoProcessingStatus:function(){this.config.slide.hasAttribute("data-background-video-processing")&&this.config.slide.hasAttribute("data-background-media-id")&&(this.videoModel||(this.videoModel=new SL.models.Video({id:this.config.slide.getAttribute("data-background-media-id")})),this.videoModel.load().then(function(){this.videoModel.isProcessed()?this.config.slide.removeAttribute("data-background-video-processing","true"):(this.videoModel.processingCompleted.add(this.onVideoProcessingCompleted),this.videoModel.processingFailed.add(this.onVideoProcessingFailed)),this.syncVideo()}.bind(this),function(){this.syncVideo()}.bind(this)))},syncVideo:function(){if(this.videoElement){this.videoElement.empty();var t=this.config.slide.getAttribute("data-background-video");this.videoModel&&this.videoModel.isLoading()?(this.renderVideoLoadingState(),this.toggleAccordion("background-video",!0)):this.videoModel&&this.videoModel.isUploading()?(this.renderVideoUploadingState(),this.toggleAccordion("background-video",!0)):this.videoModel&&this.videoModel.isProcessing()?(this.renderVideoProcessingState(),this.toggleAccordion("background-video",!0)):"string"==typeof t&&t.length?(this.renderVideoUploadedState(),this.toggleAccordion("background-video",!0)):this.toggleAccordion("background-video",!1)}},renderVideoLoadingState:function(){var t=$('<div class="upload-progress"></div>').appendTo(this.videoElement);t.append('<span class="spinner" data-spinner-color="#444"></span>'),t.append('<span class="label">Loading...</span>'),SL.util.html.generateSpinners()},renderVideoUploadingState:function(){var t=$('<div class="upload-progress"></div>').appendTo(this.videoElement);t.append('<span class="spinner" data-spinner-color="#444"></span>'),t.append('<span class="label">Uploading...</span>'),SL.util.html.generateSpinners()},renderVideoProcessingState:function(){var t=$('<div class="upload-progress"></div>').appendTo(this.videoElement);t.append('<span class="spinner" data-spinner-color="#444"></span>'),t.append('<span class="label">Processing...</span>'),SL.util.html.generateSpinners()},renderVideoUploadedState:function(){if(this.videoElement.append(['<div class="video-options">','<div class="unit sl-checkbox outline">','<input id="video-muted-checkbox" class="video-muted-input" type="checkbox" />','<label for="video-muted-checkbox">Mute</label>',"</div>",'<div class="unit sl-checkbox outline">','<input id="video-loop-checkbox" class="video-loop-input" type="checkbox" />','<label for="video-loop-checkbox">Loop</label>',"</div>",'<div class="unit">','<select class="sl-select video-size-input">','<option value="contain">Letterbox</option>','<option value="">Fullscreen</option>',"</select>","</div>",'<div class="media-opacity-wrapper"></div>',"</div>"].join("")),this.config.slide.hasAttribute("data-background-video-thumb")){var t=$(['<div class="media-thumbnail clickable" data-tooltip="Click to replace">','<div class="media-thumbnail-inner" style="background-image: url(\''+this.config.slide.getAttribute("data-background-video-thumb")+"')\"></div>","</div>"].join(""));t.on("vclick",this.browseForVideo.bind(this)),t.prependTo(this.videoElement.find(".video-options"))}var e=this.videoElement.find(".video-muted-input");e.prop("checked","true"==this.config.slide.getAttribute("data-background-video-muted")),e.on("change",function(){e.is(":checked")?this.config.slide.setAttribute("data-background-video-muted","true"):this.config.slide.removeAttribute("data-background-video-muted"),Reveal.syncSlide(this.config.slide)}.bind(this));var i=this.videoElement.find(".video-loop-input");i.prop("checked","true"==this.config.slide.getAttribute("data-background-video-loop")),i.on("change",function(){i.is(":checked")?this.config.slide.setAttribute("data-background-video-loop","true"):this.config.slide.removeAttribute("data-background-video-loop"),Reveal.syncSlide(this.config.slide)}.bind(this));var n=this.videoElement.find(".video-size-input");n.val(this.config.slide.getAttribute("data-background-size")||""),n.on("change",function(){var t=n.val();t?this.config.slide.setAttribute("data-background-size",t):this.config.slide.removeAttribute("data-background-size"),
Reveal.syncSlide(this.config.slide),this.refreshVideoThumbnail()}.bind(this)),this.renderOpacityRange().appendTo(this.videoElement.find(".media-opacity-wrapper")),this.refreshVideoThumbnail()},refreshVideoThumbnail:function(){var t=this.videoElement.find(".media-thumbnail-inner");if(t.length){var e=document.querySelector(".reveal").getBoundingClientRect(),i=e.width/e.height,n=Math.min(t.width()/i,280);t.css({height:n,"background-size":this.videoElement.find(".image-size-input").val()})}},onVideoClicked:function(t){return t?this.browseForVideo():this.removeBackgroundMedia(),SL.analytics.trackEditor("Toggle background video menu"),!1},browseForVideo:function(){var t=SL.popup.open(SL.components.medialibrary.MediaLibrary,{select:SL.models.Media.VIDEO,selectExternal:!0,selectExternalValue:this.config.slide.getAttribute("data-background-video")||""});t.selected.addOnce(function(t){this.config.slide.hasAttribute("data-background-video")||this.setVideoDefaults(),this.removeBackgroundMedia(["size","video-muted","video-loop","opacity"]),this.videoModel=t,this.syncVideo(),t.isUploaded()?this.onVideoUploadSuccess():(t.uploadCompleted.add(this.onVideoUploadSuccess),t.uploadFailed.add(this.onVideoUploadError))}.bind(this)),t.selectedExternal.addOnce(function(t){SL.util.string.isIframeVideoURL(t)?(this.removeBackgroundMedia(),this.config.slide.setAttribute("data-background-iframe",SL.util.string.formatIframeSource(t)),this.syncIframe()):(this.config.slide.hasAttribute("data-background-video")||this.setVideoDefaults(),this.removeBackgroundMedia(["size","video-muted","video-loop","opacity"]),this.config.slide.setAttribute("data-background-video",t),this.syncVideo()),Reveal.syncSlide(this.config.slide)}.bind(this))},setVideoDefaults:function(){this.config.slide.setAttribute("data-background-size","contain"),this.config.slide.setAttribute("data-background-video-muted","true"),this.config.slide.setAttribute("data-background-video-loop","true")},onVideoUploadSuccess:function(){this.videoModel&&(this.config.slide.setAttribute("data-background-video",this.videoModel.get("url")),this.config.slide.setAttribute("data-background-video-thumb",this.videoModel.get("thumb_url")),this.config.slide.setAttribute("data-background-video-processing","true"),this.config.slide.setAttribute("data-background-media-id",this.videoModel.get("id")),this.checkVideoProcessingStatus(),this.syncVideo(),Reveal.syncSlide(this.config.slide))},onVideoUploadError:function(){this.removeBackgroundMedia()},onVideoProcessingCompleted:function(){this.config.slide.removeAttribute("data-background-video-processing"),this.syncVideo(),Reveal.syncSlide(this.config.slide)},onVideoProcessingFailed:function(){this.removeBackgroundMedia()},createIframeOption:function(){this.iframeElement=$('<div class="background-iframe"></div>'),this.iframeElement.append(['<div class="iframe-options sl-form">','<div class="unit">','<p class="unit-description">Enter a secure (HTTPS) web page address to show behind the slide.</p>','<input class="iframe-url" type="text" maxlength="2000" placeholder="https://">',"</div>",'<div class="unit sl-checkbox outline">','<p class="unit-description">Enable this if you need to interact with the iframe contents.</p>','<input id="iframe-interactive-checkbox" class="iframe-interactive-input" type="checkbox" />','<label for="iframe-interactive-checkbox">Interactive</label>',"</div>",'<div class="unit sl-checkbox outline">','<p class="unit-description">Preload this iframe before it becomes visible. Not suitable for autoplaying video and audio content.</p>','<input id="iframe-preload-checkbox" class="iframe-preload-input" type="checkbox" />','<label for="iframe-preload-checkbox">Preload</label>',"</div>","</div>"].join("")),this.onIframeInput=$.debounce(this.onIframeInput.bind(this),500),this.iframeURLInput=this.iframeElement.find(".iframe-url"),this.iframeURLInput.on("keyup",this.onIframeInput),this.iframeURLInput.on("input",this.onIframeInput),this.iframeURLInput.on("blur",this.onIframeBlur.bind(this));var t=this.iframeElement.find(".iframe-interactive-input");t.prop("checked","true"==this.config.slide.getAttribute("data-background-interactive")),t.on("change",function(){t.is(":checked")?this.config.slide.setAttribute("data-background-interactive","true"):this.config.slide.removeAttribute("data-background-interactive"),Reveal.syncSlide(this.config.slide)}.bind(this));var e=this.iframeElement.find(".iframe-preload-input");return e.prop("checked",this.config.slide.hasAttribute("data-preload")),e.on("change",function(){e.is(":checked")?this.config.slide.setAttribute("data-preload",""):this.config.slide.removeAttribute("data-preload"),Reveal.syncSlide(this.config.slide)}.bind(this)),{value:"background-iframe",title:"Iframe",beforeTitle:'<span class="icon i-browser"></span>',collapseTooltip:"Remove background iframe",content:this.iframeElement,callback:this.onIframeClicked.bind(this)}},syncIframe:function(){this.config.slide.hasAttribute("data-background-iframe")?(this.iframeURLInput.val(this.config.slide.getAttribute("data-background-iframe")),this.toggleAccordion("background-iframe",!0),this.checkXFrameOptions()):(this.iframeURLInput.val(""),this.toggleAccordion("background-iframe",!1))},checkXFrameOptions:function(){var t=this.config.slide.getAttribute("data-background-iframe");SL.editor.controllers.URL.isBlockedByXFrameOptions(t).then(function(e){this.config.slide.getAttribute("data-background-iframe")===t&&(e?this.showXFrameWarning():this.hideXFrameWarning())}.bind(this),function(){this.config.slide.getAttribute("data-background-iframe")===t&&this.hideXFrameWarning()}.bind(this))},hideXFrameWarning:function(){this.domElement.find(".iframe-url-warning").remove()},showXFrameWarning:function(){this.domElement.find(".iframe-url-warning").remove(),this.iframeURLInput.after('<div class="iframe-url-warning">'+SL.locale.get("BLOCKED_BY_X_FRAME_OPTIONS")+"</div>")},hasValidIframeValue:function(){return SL.util.string.URL_REGEX.test(this.getIframeInputValue())},getIframeInputValue:function(){return SL.util.string.formatIframeSource(this.iframeURLInput.val())},onIframeInput:function(){this.hasValidIframeValue()?(this.config.slide.setAttribute("data-background-iframe",this.getIframeInputValue()),this.checkXFrameOptions()):(this.config.slide.removeAttribute("data-background-iframe"),this.hideXFrameWarning()),Reveal.syncSlide(this.config.slide)},onIframeBlur:function(){this.iframeURLInput.val(this.getIframeInputValue())},onIframeClicked:function(t){return this.removeBackgroundMedia(),t?(this.toggleAccordion("background-iframe",!0),this.iframeURLInput.focus()):this.iframeURLInput.blur(),SL.analytics.trackEditor("Toggle background iframe menu"),!1},renderOpacityRange:function(){var t=100*parseFloat(this.config.slide.getAttribute("data-background-opacity"));t="number"!=typeof t||isNaN(t)?100:t;var e=new SL.components.Range({value:t,minValue:0,maxValue:100,unit:"%",width:"100%",valuePrefix:"Opacity: "});return e.changed.add($.throttle(function(t){t=parseFloat(t)/100,"number"!=typeof t||isNaN(t)||(1===t?this.config.slide.removeAttribute("data-background-opacity"):this.config.slide.setAttribute("data-background-opacity",t),Reveal.syncSlide(this.config.slide))}.bind(this),200)),e},detachMediaModels:function(){this.videoModel&&(this.videoModel.uploadCompleted.remove(this.onVideoUploadSuccess),this.videoModel.uploadFailed.remove(this.onVideoUploadError),this.videoModel.processingCompleted.remove(this.onVideoProcessingCompleted),this.videoModel.processingFailed.remove(this.onVideoProcessingFailed),this.videoModel=null),this.imageModel&&(this.imageModel.uploadCompleted.remove(this.onImageUploadSuccess),this.imageModel.uploadFailed.remove(this.onImageUploadError),this.imageModel=null)},destroy:function(){Reveal.isFirstSlide()&&SL.editor.controllers.Thumbnail.invalidate(),this.detachMediaModels(),this.hasValidIframeValue()||this.config.slide.removeAttribute("data-background-interactive"),SL.view.colorpicker.isVisible()&&SL.view.colorpicker.detach(),this._super.apply(this,arguments)}}),SL("components.prompts").SlideSettings=SL.components.Prompt.extend({init:function(t){this.config=t,this._super($.extend({type:"form",className:"sl-slide-settings-prompt",confirmLabel:"Save"+SL.util.getKeyboardShortcutName("Enter",{meta:!0,casesensitive:!0,span:!0}),confirmButton:!0,cancelButton:!0,maxWidth:590,customFooterButtons:[{label:"",className:"visibility-button left-align light-grey",callback:this.onToggleVisibilityClicked.bind(this)}],html:this.renderSettings()},t)),this.initialState=this.getState(),this.syncSlideVisibilityButton()},renderSettings:function(){if(this.bodyElement=$('<div class="settings-body"></div>'),this.formElement=$('<div class="sl-form">').appendTo(this.bodyElement),SL.current_user.privileges.customCSS()&&SL.current_user.settings.get("developer_mode")){var t=$('<div class="half-units"></div>').appendTo(this.formElement);this.renderSlideID().appendTo(t),this.renderSlideClasses().appendTo(t)}else this.renderSlideID().appendTo(this.formElement);return this.renderAutoSlide().appendTo(this.formElement),this.renderTransition().appendTo(this.formElement),this.renderBackgroundTransition().appendTo(this.formElement),this.bodyElement},renderSlideID:function(){var t=$(['<div class="unit">','<h4 class="form-label">Slide Name</h4>','<p class="unit-description">A unique identifier that you can refer to when linking to this slide.</p>','<input class="slide-id" type="text" placeholder="A-Z, lowercase, no spaces...">',"</div>"].join(""));return this.slideIDInput=t.find(".slide-id"),this.slideIDInput.val(this.readSlideID()),this.slideIDInput.on("blur",function(){this.slideIDInput.val(SL.util.string.slug(this.slideIDInput.val().trim()))}.bind(this)),t},renderAutoSlide:function(){this.syncAutoSlideSelection=$.throttle(this.syncAutoSlideSelection,100);var t=$(['<div class="unit text">','<h4 class="form-label">Auto-Slide Duration</h4>','<p class="unit-description">The number of seconds that this slide should remain visible before automatically proceeding to the next slide. Overrides the presentation-level auto-slide setting.</p>','<div class="suffixed-input">','<input class="auto-slide" type="number" placeholder="Duration in seconds...">','<div class="suffix text-faded"><span>seconds</span></div>',"</div>",'<div class="input-field-tray input-field-tray-presets">',"</div>","</div>"].join(""));this.autoSlidePresets=t.find(".input-field-tray-presets");var e=SL.config.AUTO_SLIDE_OPTIONS.map(function(t){return{label:t+"s",value:t}}),i=Reveal.getCurrentSlide().querySelectorAll("video")[0];i&&i.duration>0&&e.unshift({label:"Match video &ndash; "+Math.ceil(i.duration)+"s",value:Math.ceil(i.duration)});var n=Reveal.getCurrentSlide().querySelectorAll("audio")[0];return n&&n.duration>0&&e.unshift({label:"Match audio &ndash; "+Math.ceil(n.duration)+"s",value:Math.ceil(n.duration)}),this.autoSlidePresets.append(e.map(function(t){return'<div class="input-field-tray-preset" data-duration="'+t.value+'">'+t.label+"</div>"})),this.autoSlidePresets.on("vclick",".input-field-tray-preset ",function(t){this.autoSlideInput.val(t.currentTarget.getAttribute("data-duration")),this.syncAutoSlideSelection()}.bind(this)),this.autoSlideInput=t.find(".auto-slide"),this.autoSlideInput.val(this.readAutoSlideInterval()),this.autoSlideInput.on("input",this.syncAutoSlideSelection.bind(this)),this.autoSlideInput.on("blur",function(){this.autoSlideInput.val(this.autoSlideInput.val().trim())}.bind(this)),SL.current_deck.get("auto_slide_interval")>0&&this.autoSlideInput.attr("placeholder",SL.current_deck.get("auto_slide_interval")/1e3+"s"),this.syncAutoSlideSelection(),t},renderSlideClasses:function(){var t=$(['<div class="unit">','<h4 class="form-label">Slide Classes</h4>','<p class="unit-description">Space-separated class names for this slide. Useful for targeting from the CSS editor.</p>','<input class="slide-classes" type="text" placeholder="Classes...">',"</div>"].join(""));return this.slideClassesInput=t.find(".slide-classes"),this.slideClassesInput.val(this.readSlideClasses()),t},renderTransition:function(){var t=$(['<div class="unit transition">','<h4 class="form-label">Slide Transition <button class="clear-button button outline" data-tooltip="Reset Slide Transition">Reset</button></h4>','<p class="unit-description">The animation that will be used to show and hide this slide. Overrides the presentation transition setting.</p>',"</div>"].join(""));return this.transitionClearButton=t.find(".clear-button"),this.transitionClearButton.on("vclick",this.resetTransition.bind(this)),this.transitionList=new SL.components.TransitionList({transitions:SL.config.THEME_TRANSITIONS,defaultTransitionID:SL.current_deck.get("transition"),removeDeprecated:!0}),this.transitionList.setValue(this.readTransition()),this.transitionList.appendTo(t),this.transitionList.selectionChanged.add(this.refreshTransitionClearButton.bind(this)),this.refreshTransitionClearButton(),t},renderBackgroundTransition:function(){var t=$(['<div class="unit background-transition">','<h4 class="form-label">Background Transition <button class="clear-button button outline" data-tooltip="Reset Background Transition">Reset</button></h4>','<p class="unit-description">The animation that will be used to show and hide this slide\'s background, if it has one.</p>',"</div>"].join(""));return this.backgroundTransitionClearButton=t.find(".clear-button"),this.backgroundTransitionClearButton.on("vclick",this.resetBackgroundTransition.bind(this)),this.backgroundTransitionList=new SL.components.TransitionList({transitions:SL.config.THEME_BACKGROUND_TRANSITIONS,defaultTransitionID:SL.current_deck.get("background_transition"),removeDeprecated:!0}),this.backgroundTransitionList.setValue(this.readBackgroundTransition()),this.backgroundTransitionList.appendTo(t),this.backgroundTransitionList.selectionChanged.add(this.refreshBackgroundTransitionClearButton.bind(this)),this.refreshBackgroundTransitionClearButton(),t},show:function(){this._super.apply(this,arguments),this.slideIDInput.focus()},cancel:function(){JSON.stringify(this.initialState)!==JSON.stringify(this.getState())?this.promptUnsavedChanges():this._super.apply(this,arguments)},confirm:function(){var t=this.getState();if(this.slideIDInput){var e=this.writeSlideID(t.slideID);if(e===!1)return!1;var i=this.initialState.slideID,n=t.slideID;if("string"==typeof i&&i.length>0&&n.length>0&&i!==n){var s=$('a[href="#/'+i+'"]');s.length>0&&SL.prompt({title:"You renamed a slide that is linked to internally. Do you want to update the links to point to the new name?",subtitle:'"'+i+'" > "'+n+'"',type:"select",data:[{html:"<h3>Don't update</h3>"},{html:"<h3>Update links</h3>",selected:!0,className:"positive",callback:function(){s.attr("href","#/"+n),SL.notify("Links updated")}.bind(this)}]})}}this.autoSlideInput&&this.writeAutoSlideInterval(t.autoSlide),this.slideClassesInput&&this.writeSlideClasses(t.slideClasses),this.transitionList&&(t.transition?this.config.slide.setAttribute("data-transition",t.transition):this.config.slide.removeAttribute("data-transition")),this.backgroundTransitionList&&(t.backgroundTransition?this.config.slide.setAttribute("data-background-transition",t.backgroundTransition):this.config.slide.removeAttribute("data-background-transition")),Reveal.sync(),this._super.apply(this,arguments)},getState:function(){return{slideID:this.slideIDInput.val().trim(),autoSlide:parseInt(this.autoSlideInput.val().trim(),10),slideClasses:this.slideClassesInput?this.slideClassesInput.val().trim():"",transition:this.transitionList.getValue(),backgroundTransition:this.backgroundTransitionList.getValue()}},readSlideID:function(){return this.config.slide.getAttribute("id")},writeSlideID:function(t){t=SL.util.string.slug(t);var e=document.querySelectorAll('section[id="'+t+'"]');return e.length>1||1===e.length&&e[0]!==this.config.slide?(SL.notify("This slide ID is already used for another slide.","negative"),!1):(t&&t.length?this.config.slide.setAttribute("id",t):this.config.slide.removeAttribute("id"),!0)},readAutoSlideInterval:function(t){var t=parseInt(this.config.slide.getAttribute("data-autoslide"),10);return"number"==typeof t&&!isNaN(t)&&t>0?t/1e3:""},writeAutoSlideInterval:function(t){"number"==typeof t&&!isNaN(t)&&t>0?this.config.slide.setAttribute("data-autoslide",1e3*t):this.config.slide.removeAttribute("data-autoslide")},syncAutoSlideSelection:function(){var t=parseInt(this.autoSlideInput.val().trim(),10);this.autoSlidePresets.find(".input-field-tray-preset.selected").removeClass("selected"),t&&this.autoSlidePresets.find('.input-field-tray-preset[data-duration="'+t+'"]').addClass("selected")},syncSlideVisibilityButton:function(){var t=this.domElement.find(".visibility-button");SL.editor.controllers.Markup.isSlideHidden(this.config.slide)?(t.removeClass("light-grey").addClass("grey"),t.attr("data-tooltip",SL.keyboard.getEditorShortcut("SHOW_SLIDE").tooltip),t.html('<span class="icon i-visibility_off"></span>')):(t.removeClass("grey").addClass("light-grey"),t.attr("data-tooltip",SL.keyboard.getEditorShortcut("HIDE_SLIDE").tooltip),t.html('<span class="icon i-visibility_on"></span>'))},readSlideClasses:function(){return this.config.slide.className.split(" ").filter(function(t){return SL.config.RESERVED_SLIDE_CLASSES.indexOf(t)===-1}).join(" ")},writeSlideClasses:function(t){t=t||"",t=t.trim().replace(/\s{2,}/g," ");var e=this.config.slide.className.split(" ").filter(function(t){return SL.config.RESERVED_SLIDE_CLASSES.indexOf(t)!==-1});e=e.concat(t.split(" ")),this.config.slide.className=e.join(" ")},readTransition:function(){return this.config.slide.getAttribute("data-transition")},readBackgroundTransition:function(){return this.config.slide.getAttribute("data-background-transition")},resetTransition:function(){this.transitionList.setValue(""),this.refreshTransitionClearButton()},resetBackgroundTransition:function(){this.backgroundTransitionList.setValue(""),this.refreshBackgroundTransitionClearButton()},refreshTransitionClearButton:function(){this.transitionClearButton.toggleClass("visible",!!this.transitionList.getValue())},refreshBackgroundTransitionClearButton:function(){this.backgroundTransitionClearButton.toggleClass("visible",!!this.backgroundTransitionList.getValue())},onToggleVisibilityClicked:function(){SL.editor.controllers.Markup.toggleSlideHidden(this.config.slide),this.syncSlideVisibilityButton()},onDocumentKeydown:function(t){return(t.metaKey||t.ctrlKey)&&72===t.keyCode?(SL.editor.controllers.Markup.toggleSlideHidden(Reveal.getCurrentSlide()),this.syncSlideVisibilityButton(),!1):this._super(t)},destroy:function(){this._super.apply(this,arguments),this.transitionList&&this.transitionList.destroy(),this.backgroundTransitionList&&this.backgroundTransitionList.destroy()}}),SL("components.prompts").SMS=SL.components.Prompt.extend({init:function(t){window.SLPhoneCountryCodes||console.warn("SLPhoneCountryCodes must be included on the page for the SMS prompt to work."),this._super($.extend({type:"custom",title:"Send SMS",className:"sl-sms-prompt",html:this.renderForm(),confirmLabel:"Send",confirmButton:!0,cancelButton:!0,destroyAfterConfirm:!1,endpoint:SL.endpoints.SMS_DECK(SL.current_deck.get("id"))},t))},renderForm:function(){return this.formElement=$(['<div class="sl-form">','<select class="sl-select country-selector">',window.SLPhoneCountryCodes.map(function(t){return'<option value="'+t.code+'">'+t.name+"</option>"}).join(""),"</select>",'<div class="unit text">','<div class="prefixed-input">','<div class="prefix"><span class="country-code"></span></div>','<input class="phone-number" type="text" placeholder="555 5555" maxlength="50" />',"</div>","</div>","</div>"].join("")),this.countrySelector=this.formElement.find(".country-selector"),this.countrySelector.on("change",this.onCountryChanged.bind(this)),this.countryCodeOutput=this.formElement.find(".country-code"),this.phoneNumberInput=this.formElement.find(".phone-number"),this.phoneNumberInput.on("change",this.onPhoneNumberChanged.bind(this)),this.restoreSavedFormValues(),this.formElement},restoreSavedFormValues:function(){SL.current_user&&(SL.current_user.settings.has("phone_country_code")?this.setCountryCode(SL.current_user.settings.get("phone_country_code")):this.setCountryCode(window.SLPhoneCountryCodes[0].code),SL.current_user.settings.has("phone_number")&&this.setPhoneNumber(SL.current_user.settings.get("phone_number")))},setCountryCode:function(t){this.countrySelector.val(t),this.countryCodeOutput.html("+"+t)},getCountryCode:function(){return this.countrySelector.val()},setPhoneNumber:function(t){this.formatPhoneNumber(t)},getPhoneNumber:function(t){var e=this.formatPhoneNumber();return t&&(e=e.replace(/\s/,"")),e},formatPhoneNumber:function(t){switch(t=t||this.phoneNumberInput.val(),t=t.trim(),t=t.replace(/[^0-9]/g,""),parseInt(this.getCountryCode(),10)){case 1:t=t.replace(/(\d{3})(\d{3})(\d+)/,"$1 $2 $3");break;case 46:t=t.replace(/(\d{2})(\d{3})(\d{2})(\d+)/,"$1 $2 $3 $4")}return this.phoneNumberInput.val(t),t},show:function(){this._super.apply(this,arguments),this.countrySelector.focus()},confirm:function(){this._super.apply(this,arguments);var t=this.getCountryCode(),e=this.getPhoneNumber(!0);t&&e?(this.showOverlay("neutral","Sending",'<div class="spinner" data-spinner-color="#333"></div>'),SL.util.html.generateSpinners(),$.ajax({url:this.config.endpoint,type:"POST",context:this,data:{phone_number:e,country_code:t}}).done(function(){this.showOverlay("positive","SMS sent!",'<span class="icon i-checkmark"></span>',2e3).then(function(){SL.current_user&&(SL.current_user.settings.set("phone_number",e),SL.current_user.settings.set("phone_country_code",t)),this.destroy()}.bind(this))}).fail(function(t){t.responseJSON&&t.responseJSON.phone_number&&t.responseJSON.phone_number.length>0?this.showOverlay("negative",'Failed to send SMS: <br>"'+value+'" '+t.responseJSON.phone_number[0],'<span class="icon i-x"></span>',2e3):this.showOverlay("negative","Failed to send SMS.",'<span class="icon i-x"></span>',2e3)})):this.showOverlay("negative","Please enter a valid phone number",'<span class="icon i-x"></span>',2e3)},onCountryChanged:function(t){this.setCountryCode(t.target.value),this.formatPhoneNumber(),this.phoneNumberInput.focus()},onPhoneNumberChanged:function(){this.formatPhoneNumber()},destroy:function(){this._super.apply(this,arguments)}}),SL("components.prompts").Unsubscribe=SL.components.Prompt.extend({init:function(t){this.visibilitySelected=new signals.Signal,this._super($.extend({type:"custom",title:"We're sorry to see you go! Before you do, would you mind letting us know why?",className:"sl-unsubscribe-prompt",html:this.renderForm(),maxWidth:420,confirmLabel:"Cancel subscription",confirmButton:!0,cancelLabel:"Dismiss",cancelButton:!0},t)),this.config.footnote&&this.formElement.append('<p class="cancellation-footnote">'+this.config.footnote+"</p>")},renderForm:function(){var t=SL.util.array.shuffle([['<input type="radio" name="cancellation-reason-code" value="1" id="cancellation-1"><label class="cancellation-radio" for="cancellation-1">I don\'t use the service frequently enough</label>'],['<input type="radio" name="cancellation-reason-code" value="2" id="cancellation-2"><label class="cancellation-radio" for="cancellation-2">I prefer PowerPoint, Keynote, or other desktop app</label><input type="radio" name="cancellation-reason-code" value="3" id="cancellation-3"><label class="cancellation-radio" for="cancellation-3">I prefer Prezi, Google Slides, or other cloud-based app</label>'],['<input type="radio" name="cancellation-reason-code" value="4" id="cancellation-4"><label class="cancellation-radio" for="cancellation-4">Missing key feature(s). Please explain below</label>']]);return t.push('<input type="radio" name="cancellation-reason-code" value="5" id="cancellation-5"><label class="cancellation-radio" for="cancellation-5">Other reason</label>'),this.formElement=$(['<div class="sl-form">','<div class="unit radio">',t.join(""),"</div>",'<div class="unit text" style="display: none;">',"<label>Additional comments</label>",'<textarea class="cancellation-notes" type="text" maxlength="1000" rows="4" />',"</div>","</div>"].join("")),this.formElement.find('input[name="cancellation-reason-code"]').one("change",this.showCancellationNotes.bind(this)),this.formElement},showCancellationNotes:function(){this.formElement.find(".cancellation-notes").parent().show(),this.formElement.find(".cancellation-notes").focus(),this.layout()},getCancellationReasonCode:function(){var t=this.formElement.find('input[name="cancellation-reason-code"]:checked').val();return"string"==typeof t?parseInt(t,10):null},getCancellationNotes:function(){var t=this.formElement.find(".cancellation-notes").val().trim();return t.length>0?t:null},getValue:function(){var t={},e=this.getCancellationReasonCode(),i=this.getCancellationNotes();return"number"==typeof e&&(t.reason_code=e),"string"==typeof i&&(t.notes=i),t}}),SL("components").Range=Class.extend({init:function(t){this.config=$.extend({value:0,width:"100%",minValue:0,maxValue:100,stepSize:null,decimals:0,unit:null,valuePrefix:"",style:"",progressBar:!0},t),this.setMinMaxValue(this.config.minValue,this.config.maxValue),this.changing=!1,this.mouseDownValue=0,this.mouseDownX=0,this.render(),this.bind(),this.setValue(this.config.value,!1)},render:function(){this.domElement=$('<div class="sl-range"></div>'),this.domElement.width(this.config.width),"string"==typeof this.config.style&&this.domElement.attr("data-style",this.config.style),this.config.progressBar===!1&&this.domElement.attr("data-progress-bar","hidden"),this.progressElement=$('<div class="sl-range-progress">').appendTo(this.domElement),this.inputElement=$('<input class="sl-range-number input-field" type="text">').appendTo(this.domElement)},bind:function(){this.changed=new signals.Signal,this.changeStarted=new signals.Signal,this.changeEnded=new signals.Signal,this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.domElement.on("vmousedown",this.onMouseDown),this.inputElement.on("input",this.onInput.bind(this)),this.inputElement.on("keydown",this.onInputKeyDown.bind(this)),this.inputElement.on("focus",this.onInputFocused.bind(this)),this.inputElement.on("blur",this.onInputBlurred.bind(this))},appendTo:function(t){this.domElement.appendTo(t)},setMinMaxValue:function(t,e){this.config.minValue=t,this.config.maxValue=e,this.valueRange=e-t,"number"!=typeof this.config.stepSize&&(this.config.stepSize=this.valueRange<=1?this.valueRange/100:1)},setValue:function(t,e,i){var n=this.value;if(this.value=Math.max(Math.min(t,this.config.maxValue),this.config.minValue),this.value=this.roundValue(this.value),!i){var s=this.value;this.config.decimals>0&&(s=s.toFixed(this.config.decimals)),this.config.unit&&(s+=this.config.unit),this.inputElement.val((this.config.valuePrefix||"")+s)}var o=this.valueToPercent(this.value)/100;this.progressElement.css("transform","scaleX("+o+")"),e&&this.value!==n&&this.changed.dispatch(this.value)},getValue:function(){return this.value},roundValue:function(t){var e=Math.pow(10,this.config.decimals);return Math.round(t*e)/e},valueToPercent:function(t){var e=(t-this.config.minValue)/(this.config.maxValue-this.config.minValue)*100;return Math.max(Math.min(e,100),0)},isChanging:function(){return this.changing},focus:function(){this.inputElement.focus()},onChangeStart:function(){this.isChanging()||(this.domElement.addClass("is-changing"),this.changing=!0,this.changeStarted.dispatch())},onChangeEnd:function(){this.isChanging()&&(this.domElement.removeClass("is-changing"),this.changing=!1,this.changeEnded.dispatch())},onMouseDown:function(t){this.inputElement.is(":focus")||t.preventDefault(),$(document).on("vmousemove",this.onMouseMove),$(document).on("vmouseup",this.onMouseUp),this.mouseDownX=t.clientX,this.mouseDownValue=this.getValue(),this.onChangeStart()},onMouseMove:function(t){this.domElement.addClass("is-scrubbing");var e=t.clientX-this.mouseDownX;1===this.config.stepSize&&this.valueRange<15?e*=.25:1===this.config.stepSize&&this.valueRange<30?e*=.5:1===this.config.stepSize&&this.valueRange<=100&&(e*=.75),this.setValue(this.mouseDownValue+e*this.config.stepSize,!0)},onMouseUp:function(t){$(document).off("vmousemove",this.onMouseMove),$(document).off("vmouseup",this.onMouseUp),this.domElement.hasClass("is-scrubbing")===!1?this.onClick(t):this.onChangeEnd(),this.domElement.removeClass("is-scrubbing")},onClick:function(){this.inputElement.focus()},onInput:function(){var t=this.inputElement.val().replace(/\D\./g,"");t=parseFloat(t),t=isNaN(t)?0:t,this.setValue(t,!0,!0)},onInputKeyDown:function(t){var e=0;38===t.keyCode?e=this.config.stepSize:40===t.keyCode&&(e=-this.config.stepSize),e&&(t.shiftKey&&(e*=10),this.setValue(this.getValue()+e,!0),t.preventDefault())},onInputFocused:function(){this.onChangeStart()},onInputBlurred:function(){this.onChangeEnd(),this.setValue(this.getValue(),!0)},destroy:function(){$(document).off("vmousemove",this.onMouseMove),$(document).off("vmouseup",this.onMouseUp),this.changed.dispose(),this.changeStarted.dispose(),this.changeEnded.dispose(),this.domElement.remove()}}),SL("components").Resizer=Class.extend({init:function(t,e){this.domElement=$(t),this.revealElement=this.domElement.closest(".reveal"),this.options=$.extend({padding:10,preserveAspectRatio:!1,useOverlay:!1},e),this.mouse={x:0,y:0},this.mouseStart={x:0,y:0},this.origin={x:0,y:0,width:0,height:0},this.resizing=!1,this.domElement.length?(this.onAnchorMouseDown=this.onAnchorMouseDown.bind(this),this.onDocumentMouseMove=this.onDocumentMouseMove.bind(this),this.onDocumentMouseUp=this.onDocumentMouseUp.bind(this),this.onElementDrop=this.onElementDrop.bind(this),this.layout=this.layout.bind(this),this.build(),this.bind(),this.layout()):console.warn("Resizer: invalid resize target.")},build:function(){this.options.useOverlay&&(this.overlay=$('<div class="editing-ui resizer-overlay"></div>').appendTo(document.body).hide()),this.anchorN=$('<div class="editing-ui resizer-anchor" data-direction="n"></div>').appendTo(document.body),this.anchorE=$('<div class="editing-ui resizer-anchor" data-direction="e"></div>').appendTo(document.body),this.anchorS=$('<div class="editing-ui resizer-anchor" data-direction="s"></div>').appendTo(document.body),this.anchorW=$('<div class="editing-ui resizer-anchor" data-direction="w"></div>').appendTo(document.body)},bind:function(){this.resizeStarted=new signals.Signal,this.resizeUpdated=new signals.Signal,this.resizeEnded=new signals.Signal,this.getAnchors().on("mousedown",this.onAnchorMouseDown),this.revealElement.on("drop",this.onElementDrop),$(document).on("keyup",this.layout),$(document).on("mouseup",this.layout),$(document).on("mousewheel",this.layout),$(document).on("DOMMouseScroll",this.layout),$(window).on("resize",this.layout)},layout:function(){if(!this.destroyIfDetached()){var t=SL.util.getRevealElementGlobalOffset(this.domElement),e=Reveal.getScale(),i=parseInt(this.domElement.css("margin-right"),10);marginBottom=parseInt(this.domElement.css("margin-bottom"),10);var n=t.x-this.options.padding,s=t.y-this.options.padding,o=(this.domElement.width()+i)*e+2*this.options.padding;height=(this.domElement.height()+marginBottom)*e+2*this.options.padding;var a=-this.anchorN.outerWidth()/2;this.anchorN.css({left:n+o/2+a,top:s+a}),this.anchorE.css({left:n+o+a,top:s+height/2+a}),this.anchorS.css({left:n+o/2+a,top:s+height+a}),this.anchorW.css({left:n+a,top:s+height/2+a}),this.overlay&&this.overlay.css({left:n,top:s,width:o,height:height})}},show:function(){this.getAnchors().addClass("visible"),this.layout()},hide:function(){this.getAnchors().removeClass("visible")},destroyIfDetached:function(){return 0===this.domElement.closest("body").length&&(this.destroy(),!0)},getOptions:function(){return this.options},getAnchors:function(){return this.anchorN.add(this.anchorE).add(this.anchorS).add(this.anchorW)},isResizing:function(){return!!this.resizing},isDestroyed:function(){return!!this.destroyed},onAnchorMouseDown:function(t){var e=$(t.target).attr("data-direction");if(e){t.preventDefault(),this.resizeDirection=e,this.mouseStart.x=t.clientX,this.mouseStart.y=t.clientY;var i=SL.util.getRevealElementOffset(this.domElement);this.origin.x=i.x,this.origin.y=i.y,this.origin.width=this.domElement.width(),this.origin.height=this.domElement.height(),this.overlay&&this.overlay.show(),this.resizing=!0,$(document).on("mousemove",this.onDocumentMouseMove),$(document).on("mouseup",this.onDocumentMouseUp),this.resizeStarted.dispatch()}},onDocumentMouseMove:function(t){if(!this.destroyIfDetached()&&(this.mouse.x=t.clientX,this.mouse.y=t.clientY,this.resizing)){
var e=Reveal.getScale(),i=(this.mouse.x-this.mouseStart.x)/e,n=(this.mouse.y-this.mouseStart.y)/e,s="",o="";switch(this.resizeDirection){case"e":s=Math.max(this.origin.width+i,1);break;case"w":s=Math.max(this.origin.width-i,1);break;case"s":o=Math.max(this.origin.height+n,1);break;case"n":o=Math.max(this.origin.height-n,1)}if(this.options.preserveAspectRatio?(""===s&&(s=this.origin.width*(o/this.origin.height)),""===o&&(o=this.origin.height*(s/this.origin.width))):(""===s&&(s=this.domElement.css("width")),""===o&&(o=this.domElement.css("height"))),"absolute"===this.domElement.css("position")&&("n"===this.resizeDirection||"w"===this.resizeDirection))switch(this.resizeDirection){case"w":this.domElement.css("left",Math.round(this.origin.x+i));break;case"n":this.domElement.css("top",Math.round(this.origin.y+n))}this.domElement.css({width:s?s:"",height:o?o:"",maxHeight:"none",maxWidth:"none"}),this.layout(),this.resizeUpdated.dispatch()}},onDocumentMouseUp:function(){this.resizing=!1,$(document).off("mousemove",this.onDocumentMouseMove),$(document).off("mouseup",this.onDocumentMouseUp),this.overlay&&this.overlay.hide(),this.resizeEnded.dispatch()},onElementDrop:function(){setTimeout(this.layout,1)},destroy:function(){this.destroyed||(this.destroyed=!0,this.resizeStarted.dispose(),this.resizeUpdated.dispose(),this.resizeEnded.dispose(),$(document).off("mousemove",this.onDocumentMouseMove),$(document).off("mouseup",this.onDocumentMouseUp),$(document).off("keyup",this.layout),$(document).off("mouseup",this.layout),$(document).off("mousewheel",this.layout),$(document).off("DOMMouseScroll",this.layout),$(window).off("resize",this.layout),this.revealElement.off("drop",this.onElementDrop),this.getAnchors().off("mousedown",this.onAnchorMouseDown),this.anchorN.remove(),this.anchorE.remove(),this.anchorS.remove(),this.anchorW.remove(),this.overlay&&this.overlay.remove())}});SL.components.Resizer.delegateOnHover=function(t,e,i){function n(){d&&(d.destroy(),d=null,$(document).off("mousemove",a),$(document).off("mouseup",r))}function s(t,e){if(d&&d.isResizing())return!1;if(d&&c&&!c.is(t)&&n(),!d){var s={};$.extend(s,i),$.extend(s,e),c=$(t),d=new SL.components.Resizer(c,s),d.resizeUpdated.add(l),d.show(),$(document).on("mousemove",a),$(document).on("mouseup",r)}}function o(t){var e=$(t.currentTarget),i=null;e.data("resizer-options")&&(i=e.data("resizer-options")),e.data("target-element")&&(e=e.data("target-element")),s(e,i)}function a(t){if(d)if(d.isDestroyed())n();else if(!d.isResizing()){var e=Reveal.getScale(),i=SL.util.getRevealElementGlobalOffset(c),s=3*d.getOptions().padding,o={top:i.y-s,right:i.x+c.outerWidth(!0)*e+s,bottom:i.y+c.outerHeight(!0)*e+s,left:i.x-s};(t.clientX<o.left||t.clientX>o.right||t.clientY<o.top||t.clientY>o.bottom)&&n()}}function r(t){setTimeout(function(){a(t)},1)}function l(){h.dispatch(c)}t.delegate(e,"mouseover",o);var d=null,c=null,h=new signals.Signal;return{show:s,updated:h,layout:function(){d&&d.layout()},destroy:function(){n(),h.dispose(),t.undelegate(e,"mouseover",o)}}};SL("components").Resolution=Class.extend({init:function(t){if(this.config=$.extend({title:null,values:null,width:1,height:1},t),!this.config.values)throw"A list of values must be specified.";this.render(),this.bind(),this.setValue(this.config.width,this.config.height)},render:function(){this.domElement=$(['<div class="sl-resolution unit">','<div class="units">','<div class="unit size">',this.config.title?"<label>"+this.config.title+"</label>":"",'<select class="sl-select""></select>',"</div>","</div>",'<div class="custom-size">','<div class="unit text custom-width">','<div class="prefixed-input">','<div class="prefix"><span>Width</span></div>','<input size="30" type="text" class="l" maxlength="4" />',"</div>","</div>",'<div class="unit text custom-height">','<div class="prefixed-input">','<div class="prefix"><span>Height</span></div>','<input size="30" type="text" class="l" maxlength="4" />',"</div>","</div>","</div>","</div>"].join("")),this.sizeInput=this.domElement.find(".size select"),this.widthInput=this.domElement.find(".custom-width input"),this.heightInput=this.domElement.find(".custom-height input"),this.renderOptions()},appendTo:function(t){this.domElement.appendTo(t)},appendUnit:function(t){this.domElement.find(".units").append(t)},getSizeUnit:function(){return this.domElement.find(".unit.size")},renderOptions:function(){this.sizeInput.html(this.config.values.map(function(t){return'<option value="'+t.width+"x"+t.height+'">'+t.label+"</option>"}).join("")),this.sizeInput.append('<option class="custom-value" value="custom">Custom</option>')},bind:function(){this.changed=new signals.Signal,this.sizeInput.on("change",this.onSizeChange.bind(this)),this.widthInput.on("input",this.onCustomSizeChange.bind(this)),this.heightInput.on("input",this.onCustomSizeChange.bind(this))},setValue:function(t,e){var i,n,s=this.config.values.filter(function(i){return i.width===t&&i.height===e},this)[0];s?(i=s.width,n=s.height):(i=t,n=e,this.sizeInput.find(".custom-value").attr("value",i+"x"+n)),this.sizeInput.val(i+"x"+n),this.widthInput.val(i),this.heightInput.val(n),this.syncCustomSize()},getValue:function(){var t={};if(this.isCustomSize())t.width=parseInt(this.widthInput.val(),10),t.height=parseInt(this.heightInput.val(),10);else{var e=this.sizeInput.val()||"";t.width=parseInt(e.split("x")[0],10),t.height=parseInt(e.split("x")[1],10)}return(isNaN(t.width)||isNaN(t.height)||t.width<1||t.height<1)&&(t.width=this.config.width,t.height=this.config.height),t},syncCustomSize:function(){this.isCustomSize()?this.domElement.addClass("expanded"):this.domElement.removeClass("expanded")},isCustomSize:function(){return this.sizeInput.find(":selected").hasClass("custom-value")},destroy:function(){this.changed.dispose(),this.domElement.remove()},onSizeChange:function(){var t=this.getValue();this.widthInput.val(t.width),this.heightInput.val(t.height),this.syncCustomSize(),this.isCustomSize()&&this.widthInput.focus(),this.changed.dispatch()},onCustomSizeChange:function(){this.changed.dispatch()}}),SL("components").ScrollShadow=Class.extend({init:function(t){this.options=$.extend({style:"",threshold:20,shadowSize:15,minScale:.5,resizeContent:!0},t),this.bind(),this.render(),this.layout()},bind:function(){this.layout=this.layout.bind(this),this.sync=this.sync.bind(this),this.onScroll=$.throttle(this.onScroll.bind(this),80),$(window).on("resize",this.layout),this.options.contentElement.on("scroll",this.onScroll)},render:function(){this.shadowTop=$('<div class="sl-scroll-shadow-top">').appendTo(this.options.parentElement),this.shadowBottom=$('<div class="sl-scroll-shadow-bottom">').appendTo(this.options.parentElement),this.shadowTop.addClass(this.options.style),this.shadowBottom.addClass(this.options.style),this.shadowTop.height(this.options.shadowSize),this.shadowBottom.height(this.options.shadowSize)},layout:function(){var t=this.options.parentElement.height(),e=this.options.footerElement?this.options.footerElement.outerHeight():0,i=this.options.headerElement?this.options.headerElement.outerHeight():0;(this.options.resizeContent&&this.options.footerElement||this.options.headerElement)&&this.options.contentElement.css("height",t-e-i),this.sync()},sync:function(){var t=this.options.footerElement?this.options.footerElement.outerHeight():0,e=this.options.headerElement?this.options.headerElement.outerHeight():0,i=this.options.contentElement.scrollTop(),n=this.options.contentElement.prop("scrollHeight"),s=this.options.contentElement.outerHeight(),o=n>s+this.options.threshold,a=i/(n-s);isNaN(a)&&(a=0),this.shadowTop.css({opacity:o?a:0,top:0===e?"":e,transform:"scaleY("+Math.min(a+this.options.minScale,1)+")"}),this.shadowBottom.css({opacity:o?1-a:0,bottom:0===t?"":t,transform:"scaleY("+Math.min(1-a+this.options.minScale,1)+")"})},onScroll:function(){this.sync()},destroy:function(){$(window).off("resize",this.layout),this.options.contentElement.off("scroll",this.onScroll),this.options=null}}),SL("components").Search=Class.extend({init:function(t){this.config=t,this.searchForm=$(".search-form"),this.searchFormInput=this.searchForm.find(".search-term"),this.searchFormSubmit=this.searchForm.find(".search-submit"),this.searchFormClear=this.searchForm.find(".search-clear"),this.searchResults=$(".search-results"),this.searchResultsHeader=this.searchResults.find("header"),this.searchResultsTitle=this.searchResults.find(".search-results-title"),this.searchResultsSorting=this.searchResults.find(".search-results-sorting"),this.searchResultsList=this.searchResults.find("ul"),this.searchFormLoader=Ladda.create(this.searchFormSubmit.get(0)),this.bind(),this.checkQuery()},bind:function(){$(".search-keywords button").on("vclick",this.onSearchKeywordClicked.bind(this)),this.searchForm.on("submit",this.onSearchFormSubmit.bind(this)),this.searchFormClear.on("vclick",this.onSearchClearClicked.bind(this)),this.searchResultsSorting.find("input[type=radio]").on("click",this.onSearchSortingChange.bind(this))},checkQuery:function(){var t=SL.util.getQuery();t.search&&!this.searchFormInput.val()&&(this.searchFormInput.val(t.search),t.page?this.search(t.search,parseInt(t.page,10)):this.search(t.search))},renderSearchResults:function(t){if($(".search").add(this.searchResults).addClass("has-searched"),this.searchResults.show(),this.searchResultsList.empty(),this.renderSearchPagination(t),t.results&&t.results.length){this.searchResultsTitle.text(t.total+" "+SL.util.string.pluralize("result","s",t.total>1)+' for "'+this.searchTerm+'"');for(var e=0,i=t.results.length;e<i;e++){var n=t.results[e];n.user&&this.searchResultsList.append(this.renderDeckThumbnail(n))}}else this.searchResultsTitle.text(t.error||SL.locale.get("SEARCH_NO_RESULTS_FOR",{term:this.searchTerm}))},renderSearchPagination:function(t){"undefined"==typeof t.decks_per_page&&(t.decks_per_page=8);var e=Math.ceil(t.total/t.decks_per_page);this.searchPagination&&this.searchPagination.remove(),e>1&&(this.searchPagination=$('<div class="search-results-pagination"></div>').appendTo(this.searchResultsHeader),this.searchPagination.append('<span class="page">'+SL.locale.get("SEARCH_PAGINATION_PAGE")+" "+this.searchPage+"/"+e+"</span>"),this.searchPage>1&&this.searchPagination.append('<button class="button outline previous">'+SL.locale.get("PREVIOUS")+"</button>"),this.searchPagination.append('<button class="button outline next">'+SL.locale.get("NEXT")+"</button>"),this.searchPagination.find("button.previous").on("click",function(){this.search(this.searchTerm,Math.max(this.searchPage-1,1))}.bind(this)),this.searchPagination.find("button.next").on("click",function(){this.search(this.searchTerm,Math.min(this.searchPage+1,e))}.bind(this)))},renderDeckThumbnail:function(t){var e=['<li class="sl-deck-thumbnail" data-preview-url="${DECK_URL}">','<a class="deck-link" href="${DECK_URL}"></a>','<div class="deck-thumb">','<img class="deck-thumb-image" src="${DECK_THUMB_URL}" loading="lazy"></img>',"</div>",'<footer class="deck-details">','<div class="top">','<div class="title"></div>',"</div>",'<div class="bottom">','<a class="author" href="${USER_URL}">','<span class="picture" style="background-image: url(${USER_THUMB_URL})"></span>','<span class="name"></span>',"</a>",'<div class="stats">','<div>${DECK_VIEWS}<span class="icon i-eye"></span></div>',"</div>","</div>","</footer>","</li>"].join(""),i={DECK_URL:t.user.username+"/"+t.slug,DECK_VIEWS:"number"==typeof t.view_count?SL.util.string.viewCount(t.view_count):"N/A",DECK_THUMB_URL:t.thumbnail_url||SL.config.DEFAULT_DECK_THUMBNAIL,USER_URL:"/"+t.user.username,USER_THUMB_URL:t.user.thumbnail_url||SL.config.DEFAULT_USER_THUMBNAIL};for(var n in i)e=e.split("${"+n+"}").join(i[n]);var s=$(e);return s.find(".title").text(t.title),s.find(".author .name").text(t.user.name||t.user.username),s},search:function(t,e,i){if(this.searchTerm=t||this.searchFormInput.val(),this.searchPage=e||1,this.searchSort=i||this.searchSort,window.history&&"function"==typeof window.history.replaceState){var n="?search="+encodeURIComponent(this.searchTerm);e>1&&(n+="&page="+e),window.history.replaceState(null,null,window.location.pathname+n)}this.searchSort||(this.searchSort=this.searchResultsSorting.find("input[type=radio]:checked").val()),this.searchResultsSorting.find("input[type=radio]").prop("checked",!1),this.searchResultsSorting.find("input[type=radio][value="+this.searchSort+"]").prop("checked",!0),this.searchTerm?(this.searchFormLoader.start(),$.ajax({type:"GET",url:this.config.url,context:this,data:{q:this.searchTerm,page:this.searchPage,sort:this.searchSort}}).done(function(t){this.renderSearchResults(t)}).fail(function(){this.renderSearchResults({error:SL.locale.get("SEARCH_SERVER_ERROR")})}).always(function(){this.searchFormLoader.stop()})):SL.notify(SL.locale.get("SEARCH_NO_TERM_ERROR"))},sort:function(t){this.search(this.searchTerm,this.searchPage,t)},onSearchFormSubmit:function(t){return this.search(),t.preventDefault(),!1},onSearchClearClicked:function(t){return $(".search").add(this.searchResults).removeClass("has-searched"),this.searchResultsList.empty(),window.history.replaceState(null,null,window.location.pathname),this.searchFormInput.val("").focus(),t.preventDefault(),!1},onSearchSortingChange:function(){this.sort(this.searchResultsSorting.find("input[type=radio]:checked").val())},onSearchKeywordClicked:function(t){this.searchFormInput.val(t.currentTarget.textContent),this.search()}}),SL("components").StreamPointer=Class.extend({init:function(t){this.options=$.extend({publisher:!1,stream:null,container:document.body,easing:.13,hideDefault:!1},t),this.x=0,this.y=0,this.isDown=!1,this.isOutside=!1,this.render(),this.bind()},render:function(){this.domElement=$('<div class="sl-stream-pointer">'),this.domElement.html('<svg viewBox="0 0 24 24" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M7,2l12,11.2l-5.8,0.5l3.3,7.3l-2.2,1l-3.2-7.4L7,18.5V2z"/></svg>')},bind:function(){this.hide=this.hide.bind(this),this.paint=this.paint.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.onStreamPointerChanged=this.onStreamPointerChanged.bind(this),this.broadcastPosition=$.throttle(this.broadcastPosition,SL.config.STREAM_POINTER_UPDATE_FREQUENCY),this.options.stream.pointerChanged.add(this.onStreamPointerChanged),this.options.publisher&&($(this.options.container).on("mousemove",this.onMouseMove),$(this.options.container).on("mouseleave",this.onMouseLeave),$(this.options.container).on("mouseenter",this.onMouseEnter),$(this.options.container).on("mousedown",this.onMouseDown))},setEnabled:function(t){this.enabled=t,t?(this.domElement.appendTo(this.options.container),this.show()):(this.domElement.detach(),this.hide(),this.moved=!1,this.domElement.removeClass("has-position"))},isEnabled:function(){return this.enabled},show:function(){this.isEnabled()&&($(window).on("resize",this.onWindowResize),this.domElement.addClass("visible"),this.options.hideDefault&&(this.options.container.style.cursor="none"),this.layout())},hide:function(){$(window).off("resize",this.onWindowResize),this.domElement.removeClass("visible"),this.options.hideDefault&&(this.options.container.style.cursor="")},move:function(t,e,i){this.layoutIfNecessary(),this.x=t,this.y=e,i?(this.tx=this.cx=this.x,this.ty=this.cy=this.y):(this.tx=this.slideX+this.x*this.slideScale,this.ty=this.slideY+this.y*this.slideScale),this.cx&&this.cy||(this.cx=this.tx,this.cy=this.ty),this.painting||this.paint(),this.moved||(this.moved=!0,this.domElement.addClass("has-position"))},layout:function(){var t=$(".reveal").get(0).getBoundingClientRect(),e=Reveal.getConfig();this.slideScale=Reveal.getScale(),this.slideX=t.left+(t.width/2-e.width*this.slideScale/2),this.slideY=t.top+(t.height/2-e.height*this.slideScale/2),this.domElement.css("font-size",Math.round(34*Math.max(Math.min(this.slideScale,1),.6)))},layoutIfNecessary:function(){"undefined"==typeof this.slideScale&&this.layout()},paint:function(){this.cx+=(this.tx-this.cx)*this.options.easing,this.cy+=(this.ty-this.cy)*this.options.easing,this.domElement.css("transform","translate("+this.cx+"px,"+this.cy+"px)"),Math.abs(this.cx-this.tx)>.5||Math.abs(this.cy-this.ty)>.5?(window.requestAnimationFrame(this.paint),this.painting=!0):this.painting=!1},broadcastPosition:function(t){if(this.isEnabled()&&this.options.publisher){this.layoutIfNecessary();var e=Math.round((this.mouseX-this.slideX)/this.slideScale),i=Math.round((this.mouseY-this.slideY)/this.slideScale);this.options.stream.broadcast($.extend({type:"live:pointer",x:e,y:i},t))}},destroy:function(){window.cancelAnimationFrame(this.paint),this.options.stream.pointerChanged.remove(this.onStreamPointerChanged),$(window).off("resize",this.onWindowResize),$(document).off("mouseup",this.onMouseUp),this.options.publisher&&($(this.options.container).off("mousemove",this.onMouseMove),$(this.options.container).off("mouseleave",this.onMouseLeave),$(this.options.container).off("mouseenter",this.onMouseEnter),$(this.options.container).off("mousedown",this.onMouseDown)),this.options=null,this.domElement.remove()},onWindowResize:function(){this.layout(),this.move(this.x,this.y)},onStreamPointerChanged:function(t){"number"==typeof t.x&&"number"==typeof t.y&&this.move(t.x,t.y),"boolean"==typeof t.outside&&(this.isOutside=t.outside,this.isOutside?this.hide():this.show()),"boolean"==typeof t.down&&(this.isDown=t.down,this.domElement.toggleClass("is-down",this.isDown))},onMouseMove:function(t){this.mouseX=t.clientX,this.mouseY=t.clientY,this.isEnabled()&&(this.move(this.mouseX,this.mouseY,!0),this.broadcastPosition())},onMouseLeave:function(t){this.isOutside=!0,this.hide(),this.isEnabled()&&this.options.stream.broadcast({type:"live:pointer",outside:!0,down:!1}),this.isDown&&this.onMouseUp(t)},onMouseEnter:function(){this.isOutside=!1,this.show(),this.isEnabled()&&this.options.stream.broadcast({type:"live:pointer",outside:!1,down:!1})},onMouseDown:function(){this.isDown=!0,this.domElement.toggleClass("is-down",!0),this.isEnabled()&&this.broadcastPosition({down:!0}),$(document).on("mouseup",this.onMouseUp)},onMouseUp:function(){this.isDown=!1,this.domElement.toggleClass("is-down",!1),this.isEnabled()&&this.broadcastPosition({down:!1}),$(document).off("mouseup",this.onMouseUp)}}),SL("components").TemplatesBasePage=Class.extend({init:function(t){this.options=t||{},this.visible=!1,this.templateSelected=new signals.Signal,this.render()},render:function(){this.domElement=$('<div class="page" data-page-id="'+this.options.id+'">'),this.contentElement=$('<div class="page-content">').appendTo(this.domElement)},renderTemplates:function(){this.actionList=$('<div class="action-list">').appendTo(this.contentElement),this.templateList=$('<div class="template-list no-transition">').appendTo(this.contentElement),this.options.templates.forEach(this.renderTemplate.bind(this)),(this.isDefaultTemplates()||this.isTeamTemplates()&&this.getNumberOfVisibleTemplates()>0)&&(this.blankTemplate=this.renderBlankTemplate(),this.duplicateTemplate=this.renderDuplicateTemplate())},renderBlankTemplate:function(t){return t=$.extend({container:this.actionList,editable:!1},t),this.renderTemplate(new SL.models.Template({label:"Blank",html:""}),t)},renderDuplicateTemplate:function(t,e){t=$.extend({container:this.actionList,editable:!1},t);var i="Duplicate";return SL.editor.controllers.AutoAnimate.isEnabled(Reveal.getCurrentSlide())&&(i="Duplicate & Auto-Animate"),this.renderTemplate(new SL.models.Template({label:i,html:e||""}),t)},renderTemplate:function(t,e){e=$.extend({prepend:!1,editable:!0,container:this.templateList},e);var i=$('<div class="template-item">');i.html(['<div class="template-item-thumb themed">','<div class="template-item-thumb-content reveal reveal-thumbnail ready block-animations-disabled">','<div class="slides">',t.get("html"),"</div>",'<div class="backgrounds"></div>',"</div>","</div>"].join("")),i.data("template-model",t),i.on("vclick",this.onTemplateSelected.bind(this,i)),i.find(".slides>section").addClass("present"),i.find('.sl-block[data-block-type="code"] pre').addClass("hljs"),t.get("label")&&i.append('<span class="template-item-label">'+t.get("label")+"</span>"),e.replaceTemplate?e.replaceTemplate.replaceWith(i):e.replaceTemplateAt?e.container.find(".template-item").eq(e.replaceTemplateAt).replaceWith(i):e.prepend?e.container.prepend(i):e.container.append(i);var n=i.find("section").attr("data-background-color"),s=i.find("section").attr("data-background-image"),o=i.find("section").attr("data-background-size"),a=i.find("section").attr("data-background-position");backgroundOpacity=i.find("section").attr("data-background-opacity");var r=$('<div class="slide-background present template-item-thumb-background">');if(r.addClass(i.find(".template-item-thumb .reveal section").attr("class")),r.appendTo(i.find(".template-item-thumb .reveal>.backgrounds")),(n||s)&&(n&&r.css("background-color",n),s&&r.css("background-image",'url("'+s+'")'),o&&r.css("background-size",o),a&&r.css("background-position",a),backgroundOpacity&&r.css("opacity",backgroundOpacity)),this.isEditable()&&e.editable){var l=$('<div class="template-item-options"></div>').appendTo(i),d=$('<div class="option delete-template"><span class="icon i-trash"></span></div>');if(d.attr("data-tooltip","Delete this template"),d.on("vclick",this.onTemplateDeleteClicked.bind(this,i)),d.appendTo(l),this.isTeamTemplates()&&SL.current_user.getThemes().size()>1){var c=$('<div class="option"><span class="icon i-ellipsis-v"></span></div>');c.attr("data-tooltip","Theme availability"),c.on("vclick",this.onTemplateThemeClicked.bind(this,i)),c.appendTo(l)}}return i},refresh:function(){if(this.hasRenderedTemplates){if(!this.isVisible())return void(this.waitingToRefresh=!0);this.waitingToRefresh=!1,this.duplicateTemplate&&this.duplicateTemplate.length&&(this.duplicateTemplate=this.renderDuplicateTemplate({replaceTemplate:this.duplicateTemplate},SL.data.templates.templatize(Reveal.getCurrentSlide()))),this.templateList.find(".placeholder").remove(),this.refreshSizes();var t=SL.view.getCurrentTheme(),e=this.domElement.find(".template-item");if(this.isTeamTemplates()&&e.each(function(e,i){var n=$(i),s=n.data("template-model").isAvailableForTheme(t);n.toggleClass(SL.current_user.isEnterpriseManager()?"semi-hidden":"hidden",!s)}.bind(this)),e=this.domElement.find(".template-item:not(.hidden)"),e.length)e.each(function(e,i){var n=$(i),s=(n.data("template-model"),n.find(".template-item-thumb"));s.attr("class",s.attr("class").replace(/theme\-(font|color)\-([a-z0-9-])*/gi,"")),s.addClass("theme-font-"+t.get("font")),s.addClass("theme-color-"+t.get("color")),s.find(".template-item-thumb-content img[data-src]").each(function(){this.setAttribute("src",this.getAttribute("data-src")),this.removeAttribute("data-src")}),SL.data.templates.layoutTemplate(s.find("section"),!0)}.bind(this)),this.templateList.find(".placeholder").remove();else{var i="You haven't saved any slides yet.<br>Click <em>\""+SL.locale.get("TEMPLATE_SAVE_SLIDE_LABEL")+'"</em> to save one now.';this.isTeamTemplates()&&(i=SL.current_user.isEnterpriseManager()?'Templates saved here are available to all team members.<br>Click <em>"'+SL.locale.get("TEMPLATE_SAVE_SLIDE_LABEL")+'"</em> to save one now.':"No templates are available for the current theme."),this.templateList.append('<p class="placeholder">'+i+"</p>")}}},refreshSizes:function(){var t=Reveal.getConfig(),e=t.width,i=t.height,n=228,s=n/e,o=Math.round(i*s);this.domElement.find(".template-item-thumb").css("height",o),this.domElement.find(".template-item-thumb-content").css({width:e,height:i,transform:"scale("+s+")"})},show:function(){this.visible=!0,this.hasRenderedTemplates?this.waitingToRefresh&&this.refresh():(this.hasRenderedTemplates=!0,this.renderTemplates(),this.refresh()),this.contentElement.scrollTop(0)},hide:function(){this.visible=!1},isVisible:function(){return this.visible},saveState:function(){this.scrollPosition=this.contentElement.scrollTop()},restoreState:function(){this.scrollPosition&&this.contentElement.scrollTop(this.scrollPosition)},appendTo:function(t){this.domElement.appendTo(t)},saveCurrentSlide:function(){var t=SL.endpoints.SLIDE_TEMPLATES_CREATE;return this.isTeamTemplates()&&(t=SL.endpoints.TEAM_SLIDE_TEMPLATES_CREATE),$.ajax({type:"POST",url:t,context:this,data:{slide_template:{html:SL.data.templates.templatize(Reveal.getCurrentSlide())}}}).done(function(t){this.options.templates.create(t,{prepend:!0}).then(function(t){var e=this.renderTemplate(t,{prepend:!0}).addClass("intro-animation");this.refresh(),setTimeout(function(){e.removeClass("intro-animation")},1e3)}.bind(this)),t&&t.sanitize_messages&&t.sanitize_messages.length?SL.notify(t.sanitize_messages[0],"negative"):SL.notify(SL.locale.get("TEMPLATE_CREATE_SUCCESS"))}).fail(function(){SL.notify(SL.locale.get("TEMPLATE_CREATE_ERROR"),"negative")})},isEditable:function(){return this.isUserTemplates()||this.isTeamTemplates()&&SL.current_user.isEnterpriseManager()},isDefaultTemplates:function(){return"default"===this.options.id},isUserTemplates:function(){return"user"===this.options.id},isTeamTemplates:function(){return"team"===this.options.id},getNumberOfVisibleTemplates:function(){if(SL.current_user.isEnterpriseManager())return this.options.templates.size();var t=SL.view.getCurrentTheme();return this.options.templates.reduce(function(e,i){return e+(i.isAvailableForTheme(t)?1:0)},0)},onTemplateSelected:function(t,e){e.preventDefault(),this.templateSelected.dispatch(t.data("template-model").get("html"))},onTemplateDeleteClicked:function(t,e){return e.preventDefault(),SL.prompt({anchor:$(e.currentTarget),title:SL.locale.get("TEMPLATE_DELETE_CONFIRM"),type:"select",hoverTarget:t,data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Delete</h3>",selected:!0,className:"negative",callback:function(){var e=t.data("template-model"),i=SL.endpoints.SLIDE_TEMPLATES_DELETE(e.get("id"));this.isTeamTemplates()&&(i=SL.endpoints.TEAM_SLIDE_TEMPLATES_DELETE(e.get("id"))),$.ajax({type:"DELETE",url:i,context:this}).done(function(){t.remove(),this.refresh()})}.bind(this)}]}),!1},onTemplateThemeClicked:function(t,e){e.preventDefault();var i=SL.current_user.getThemes();if(i.size()>0){var n=t.data("template-model"),s=n.get("id"),o=n.isAvailableForAllThemes(),a=($(Reveal.getCurrentSlide()),[{value:"All themes",selected:o,exclusive:!0,className:"header-item",callback:function(){i.forEach(function(t){t.hasSlideTemplate(s)&&t.removeSlideTemplate([s]).fail(this.onGenericError)}.bind(this)),this.refresh()}.bind(this)}]);i.forEach(function(t){a.push({value:t.get("name"),selected:!o&&n.isAvailableForTheme(t),callback:function(e,i){i?t.addSlideTemplate([s]).fail(this.onGenericError):t.removeSlideTemplate([s]).fail(this.onGenericError),this.refresh()}.bind(this)})}.bind(this)),SL.prompt({anchor:$(e.currentTarget),title:"Available for...",type:"list",alignment:"l",data:a,listType:"multiselect",optional:!0,hoverTarget:t})}return!1},onGenericError:function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative")}}),SL("components").TemplatesDecksPage=SL.components.TemplatesBasePage.extend({init:function(t){this._super($.extend({deckEndpoint:SL.endpoints.DECK_LIST(),searchEndpoint:null,placeholderText:"No decks found.",showAuthor:!1,tags:null},t)),this.renderDecks=this.renderDecks.bind(this),this.renderDeck=this.renderDeck.bind(this),this.renderError=this.renderError.bind(this),this.renderedDecks=[],this.loaded=!1,this.sortValueDefault="newest-first",this.sortValue=this.sortValueDefault,this.tagFilterValueDefault="",this.tagFilterValue=this.tagFilterValueDefault,this.onPostMessage=this.onPostMessage.bind(this)},loadDecks:function(){this.deckList.html('<p class="placeholder">Loading...</p>'),this.renderedDecks.length=0,this.deckCollection&&this.deckCollection.destroy(),this.placeholderText=this.options.placeholderText;var t=this.options.deckEndpoint,e=["order="+this.sortValue];return"string"==typeof this.searchTerm&&this.searchTerm.length&&(t=this.options.searchEndpoint,e.push("q="+this.searchTerm),this.placeholderText='No results for "'+this.searchTerm+'"'),this.tagFilterValue!==this.tagFilterValueDefault&&e.push("tag_id="+this.tagFilterValue),this.deckCollection=new SL.collections.Decks(null,null,{list:t+"?"+e.join("&")}),this.deckCollection.load().then(function(){this.deckCollection.removeByProperties({id:SL.current_deck.get("id")}),this.renderDecks()}.bind(this),this.renderError.bind(this))},render:function(){this.domElement=$('<div class="page decks-page" data-page-id="'+this.options.id+'">'),this.contentElement=$('<div class="page-content">').appendTo(this.domElement),this.contentElement.on("scroll",$.debounce(this.onScroll.bind(this),200)),this.options.tags&&!this.options.tags.isLoaded()?this.options.tags.load().then(function(){this.renderFilters(),this.setupFilters()}.bind(this)):(this.renderFilters(),this.setupFilters()),this.deckList=$('<div class="deck-list">').appendTo(this.contentElement)},renderError:function(){this.loaded=!1,this.deckList.html('<p class="placeholder">Failed to load decks. <a href="#" class="retry-button">Try again</a></p>'),this.deckList.find(".retry-button").on("vclick",function(){this.loadDecks().then(this.renderDecks,this.renderError)}.bind(this))},renderDecks:function(){this.deckList.find(".placeholder").remove(),this.deckCollection.isEmpty()?$('<p class="placeholder"></p>').text(this.placeholderText).appendTo(this.deckList):this.deckCollection.forEach(this.renderDeck)},renderDeck:function(t){if(this.renderedDecks.indexOf(t.get("id"))===-1){this.renderedDecks.push(t.get("id"));var e=$(['<div class="deck-item" data-id="'+t.get("id")+'">','<div class="deck-thumb"></div>','<div class="deck-info">','<h4 class="deck-title">'+t.get("title")+"</h4>",'<div class="deck-meta">','<span class="deck-meta-item">'+t.get("slide_count")+" "+SL.util.string.pluralize("slide","s",t.get("slide_count")>1)+"</span>","</div>","</div>","</div>"].join(""));t.isVisibilitySelf()&&e.find(".deck-meta").append('<span class="deck-meta-item">Private</span>'),this.options.showAuthor&&e.find(".deck-meta").append('<a class="deck-meta-item deck-author" href="'+t.user.getProfileURL()+'" target="_blank">by '+t.user.getNameOrSlug()+"</a>"),e.find(".deck-thumb").css("background-image",'url("'+t.get("thumbnail_url")+'")'),e.on("vclick",this.onDeckClicked.bind(this,e,t)),this.deckList.append(e)}},renderFilters:function(){this.filtersElement=$(['<div class="deck-filters sl-form">','<div class="deck-filters-options">','<button class="button outline deck-filters-sort" data-tooltip="Sort decks"><span class="icon i-sort"></span></button>',"</div>","</div>"].join("")),this.options.tags&&!this.options.tags.isEmpty()&&this.filtersElement.find(".deck-filters-options").prepend('<button class="button outline deck-filters-tag-filter" data-tooltip="Filter by tag"><span class="icon i-tag-fill"></span></button>'),this.options.searchEndpoint&&this.filtersElement.find(".deck-filters-options").prepend(['<div class="deck-filters-search-wrapper">','<input class="deck-filters-search" type="text" required>','<span class="deck-filters-search-icon icon i-search" data-tooltip="Search"></span>','<span class="deck-filters-search-clear icon i-x-altx-alt" data-tooltip="Clear"></span>',"</div>"].join("")),this.filtersElement.appendTo(this.domElement)},setupFilters:function(){this.sortDecks=this.sortDecks.bind(this),this.filterByTag=this.filterByTag.bind(this),this.searchDecks=$.debounce(this.searchDecks.bind(this),500),this.domElement.find(".deck-filters-sort").on("vclick",function(t){return SL.prompt({anchor:$(t.currentTarget),title:"Sort decks",type:"list",alignment:"b",optional:!0,cancelButton:!1,data:[{value:"newest-first",title:"Newest first",selected:"newest-first"===this.sortValue,callback:this.sortDecks},{value:"oldest-first",title:"Oldest first",selected:"oldest-first"===this.sortValue,callback:this.sortDecks}]}),!1}.bind(this)),this.domElement.find(".deck-filters-tag-filter").on("vclick",function(t){return SL.prompt({anchor:$(t.currentTarget),title:"Filter by tag",type:"list",alignment:"b",optional:!0,cancelButton:!1,data:[{value:"",title:"Show all",selected:""==this.tagFilterValue,callback:this.filterByTag}].concat(this.options.tags.map(function(t){return{value:t.get("id"),title:t.get("name"),selected:this.tagFilterValue==t.get("id"),callback:this.filterByTag}}.bind(this)))}),!1}.bind(this)),this.domElement.find(".deck-filters-search, .deck-filters-search-icon").on("vclick",function(t){this.domElement.find(".deck-filters-search").focus(),
t.preventDefault()}.bind(this)),this.domElement.find(".deck-filters-search").on("input",function(t){this.searchDecks($(t.currentTarget).val())}.bind(this)),this.domElement.find(".deck-filters-search-clear").on("vclick",function(t){this.searchDecks(""),this.domElement.find(".deck-filters-search").val("").focus(),t.preventDefault()}.bind(this))},searchDecks:function(t){this.searchValue!==t&&(this.searchTerm=t,this.sortValue=this.sortValueDefault,this.filtersElement.find(".deck-filters-sort").toggleClass("is-set",this.sortValue!==this.sortValueDefault),this.loadDecks())},sortDecks:function(t){this.sortValue!==t&&(this.sortValue=t,this.filtersElement.find(".deck-filters-sort").toggleClass("is-set",this.sortValue!==this.sortValueDefault),this.searchTerm="",this.filtersElement.find(".deck-filters-search").val(""),this.loadDecks())},filterByTag:function(t){this.tagFilterValue!==t&&(this.tagFilterValue=t,this.filtersElement.find(".deck-filters-tag-filter").toggleClass("is-set",this.tagFilterValue!==this.tagFilterValueDefault),this.loadDecks())},toggleDeck:function(t,e){var i=t.is(".selected");if(this.deckList.find(".deck-item.selected").removeClass("selected loaded"),this.deckList.find(".deck-item .deck-preview iframe").off("load error"),this.deckList.find(".deck-item .deck-preview, .deck-item .deck-preloader").remove(),!i){t.addClass("selected"),t.find(".deck-thumb").append(['<div class="deck-preview">','<div class="deck-preloader">','<div class="spinner centered" data-spinner-color="#333"></div>',"</div>",'<iframe src="'+e.getURL({view:"fullscreen"})+'?showNotes=false&autoSlide=0&autoPlayMedia=false&fragments=false"></iframe>','<div class="buttons">','<button class="button grey insert-slide-button">Insert this slide</button>','<button class="button grey close-preview-button icon i-x" data-tooltip="Close preview" data-tooltip-delay="600"></button>',"</div>","</div>"].join(""));var n=t.find(".deck-preloader"),s=t.find(".deck-preview iframe");SL.util.html.generateSpinners(),s.on("load",function(){t.addClass("loaded"),n.remove()}),s.on("error",function(){n.remove()}),t.find(".insert-slide-button").on("vclick",function(t){t.preventDefault(),t.stopPropagation(),s.get(0).contentWindow.postMessage(JSON.stringify({namespace:"slides",eventName:"publish-current-slide-html"}),"*")}.bind(this)),t.find(".close-preview-button").on("vclick",function(i){i.preventDefault(),i.stopPropagation(),this.toggleDeck(t,e)}.bind(this))}},show:function(){this._super(),this.loaded||(this.loaded=!0,this.loadDecks()),window.addEventListener("message",this.onPostMessage)},hide:function(){this._super(),window.removeEventListener("message",this.onPostMessage)},onScroll:function(){var t=this.contentElement.height(),e=this.contentElement.prop("scrollHeight"),i=this.contentElement.scrollTop();i>e-2*t&&this.deckCollection.hasNextPage()&&!this.deckCollection.isLoading()&&this.deckCollection.loadNextPage().then(function(){this.deckCollection.forEach(this.renderDeck)}.bind(this))},onDeckClicked:function(t,e,i){0===$(i.target).closest("a").length&&this.toggleDeck(t,e)},onPostMessage:function(t){var e=SL.util.parseJSON(t.data);if("slides"===e.namespace&&"insert-slide"===e.eventName&&e.data){var i=SL.data.templates.templatize(e.data,{includeNotes:!0});this.templateSelected.dispatch(i,!0)}},refresh:function(){},refreshSizes:function(){}}),SL("components").Templates=Class.extend({init:function(t){this.options=$.extend({alignment:"",width:724,height:850,arrowSize:8},t),this.pages=[],this.pagesHash={},SL.data.templates.getUserTemplates(),SL.data.templates.getTeamTemplates(),this.render(),this.bind()},render:function(){this.domElement=$('<div class="sl-templates">'),this.innerElement=$('<div class="sl-templates-inner">').appendTo(this.domElement),this.arrowElement=$('<div class="sl-templates-arrow">').appendTo(this.innerElement),this.domElement.data("instance",this),this.sidebarElement=$('<div class="sl-templates-sidebar">').appendTo(this.innerElement),this.sidebarPages=$('<div class="sl-templates-sidebar-pages">').appendTo(this.sidebarElement),this.contentElement=$('<div class="sl-templates-content">').appendTo(this.innerElement),this.addTemplateButton=$(['<button class="button sl-templates-sidebar-button add-new-template ladda-button" data-style="zoom-out" data-spinner-color="#fff" data-spinner-size="32">',"<span>"+SL.locale.get("TEMPLATE_SAVE_SLIDE_LABEL")+"</span>",'<span class="icon i-plus"></span>',"</button>"].join("")),this.addTemplateButton.on("click",this.onTemplateCreateClicked.bind(this)),this.addTemplateButton.appendTo(this.sidebarElement),this.addTemplateButtonLoader=Ladda.create(this.addTemplateButton.get(0))},renderTemplates:function(){this.pages=[],this.renderPage(SL.components.TemplatesBasePage,{id:"default",label:"Slide Templates",templates:SL.data.templates.getDefaultTemplates()});var t=!!SL.current_team&&SL.current_user.isMemberOfCurrentTeam();t&&this.sidebarPages.append('<div class="sl-templates-sidebar-header">Me <span class="user-icon"></span></div>'),SL.data.templates.getUserTemplates(function(t){this.renderPage(SL.components.TemplatesBasePage,{id:"user",label:SL.locale.get("TEMPLATE_PERSONAL_TEMPLATES_LABEL"),templates:t})}.bind(this)),("undefined"==typeof window.SLDeckCount||window.SLDeckCount>0)&&this.renderPage(SL.components.TemplatesDecksPage,{id:"decks",label:SL.locale.get("TEMPLATE_PERSONAL_DECKS_LABEL"),templates:new SL.collections.Collection,tags:new SL.collections.DeckTags,placeholderText:"When you have created more than one slide deck you'll be able to insert slides from other decks here."}),t&&(this.sidebarPages.append('<div class="sl-templates-sidebar-header">My Team <span class="users-icon"></span></div>'),SL.data.templates.getTeamTemplates(function(t){!SL.current_user.isEnterpriseManager()&&t.isEmpty()||this.renderPage(SL.components.TemplatesBasePage,{id:"team",label:SL.locale.get("TEMPLATE_TEAM_TEMPLATES_LABEL"),templates:t})}.bind(this)),this.renderPage(SL.components.TemplatesDecksPage,{id:"team-decks",label:SL.locale.get("TEMPLATE_TEAM_DECKS_LABEL"),templates:new SL.collections.Collection,deckEndpoint:SL.endpoints.TEAM_DECKS_LIST,searchEndpoint:SL.endpoints.SEARCH_TEAM,placeholderText:"When your team has shared one or more public or internal slide decks you'll be able to browse them here.",showAuthor:!0}))},renderPage:function(t,e){var i=$('<div class="sl-templates-sidebar-button" data-page-id="'+e.id+'">'+e.label+"</div>");i.on("vclick",function(){this.showPage(e.id),SL.analytics.trackEditor("Slide templates tab clicked",e.id)}.bind(this)),i.appendTo(this.sidebarPages);var n=new t(e);n.templateSelected.add(this.onTemplateSelected.bind(this)),n.appendTo(this.contentElement),this.pages.push(n),this.pagesHash[e.id]=n},selectDefaultPage:function(){var t=this.pages.some(function(t){return t.isTeamTemplates()&&t.getNumberOfVisibleTemplates()>0});t?this.showPage("team"):this.showPage("default")},showPage:function(t){this.currentPage&&this.currentPage.hide(),this.currentPage=this.pagesHash[t],this.currentPage?(this.contentElement.find(".page").removeClass("past present future"),this.contentElement.find('.page[data-page-id="'+t+'"]').addClass("present"),this.contentElement.find('.page[data-page-id="'+t+'"]').prevAll().addClass("past"),this.contentElement.find('.page[data-page-id="'+t+'"]').nextAll().addClass("future"),this.sidebarElement.find(".sl-templates-sidebar-button[data-page-id]").removeClass("selected"),this.sidebarElement.find('.sl-templates-sidebar-button[data-page-id="'+t+'"]').addClass("selected"),this.currentPage.show()):console.warn('Template page "'+t+'" not found.')},refreshPages:function(){this.pages.forEach(function(t){t.refresh()})},bind:function(){this.layout=this.layout.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onClicked=this.onClicked.bind(this),this.domElement.on("vclick",this.onClicked)},layout:function(){var t=10,e=this.domElement.outerWidth(),i=this.domElement.outerHeight(),n=this.options.width,s=this.options.height,o={};n=Math.min(n,e-2*t),s=Math.min(s,i-2*t);var a=n/2,r=s/2,l=8;this.options.anchor&&(o.left=this.options.anchor.offset().left,o.top=this.options.anchor.offset().top,o.width=this.options.anchor.outerWidth(),o.height=this.options.anchor.outerHeight(),o.right=o.left+o.width,o.bottom=o.top+o.height);var d,c;this.options.anchor&&"r"===this.options.alignment?(n=Math.min(n,o.left-2*t),d=o.left-n-this.options.arrowSize-t,c=o.top+o.height/2-s/2):this.options.anchor&&"b"===this.options.alignment?(s=Math.min(s,o.top-2*t),d=o.left+o.width/2-n/2,c=o.top-s-this.options.arrowSize-t):this.options.anchor&&"l"===this.options.alignment?(n=Math.min(n,e-o.right-2*t),d=o.right+this.options.arrowSize+t,c=o.top+o.height/2-s/2):(d=(e-n)/2,c=(i-s)/2),c=Math.max(c,t),d=Math.max(d,t),this.options.anchor&&"r"===this.options.alignment?(a=n,r=o.top-c+o.height/2):this.options.anchor&&"b"===this.options.alignment?(a=o.left-d+o.width/2,r=s):this.options.anchor&&"l"===this.options.alignment?(a=-l,r=o.top-c+o.height/2):(a=o.left-d+o.width/2,r=-l),this.innerElement.css({width:n,height:s,left:d,top:c}),this.arrowElement.css({left:a,top:r})},show:function(t){this.options=$.extend(this.options,t),this.domElement.attr("data-alignment",this.options.alignment),this.domElement.appendTo(document.body),0===this.pages.length&&this.renderTemplates(),$(window).on("resize",this.layout),SL.keyboard.keydown(this.onKeyDown),this.pages.forEach(function(t){t.restoreState(),t.refresh()}),this.hasSelectedDefaultPage||(this.hasSelectedDefaultPage=!0,this.selectDefaultPage()),this.layout()},hide:function(){this.pages.forEach(function(t){t.saveState()}),this.domElement.detach(),$(window).off("resize",this.layout),SL.keyboard.release(this.onKeyDown)},onTemplateSelected:function(t,e){this.options.callback&&(e!==!0&&this.hide(),this.options.callback(t))},onTemplateCreateClicked:function(){return this.currentPage.isEditable()||this.showPage("user"),this.addTemplateButtonLoader.start(),this.currentPage.saveCurrentSlide().then(function(){this.addTemplateButtonLoader.stop()}.bind(this),function(){this.addTemplateButtonLoader.stop()}.bind(this)),this.currentPage.isTeamTemplates()?SL.analytics.trackEditor("Saved team template"):SL.analytics.trackEditor("Saved user template"),!1},onKeyDown:function(t){var e=$(document.activeElement);return 27!==t.keyCode||(e.is('input[type="text"]')&&e.closest(".sl-templates").length>0?e.blur():this.hide(),!1)},onClicked:function(t){$(t.target).is(this.domElement)&&(t.preventDefault(),this.hide())},destroy:function(){$(window).off("resize",this.layout),SL.keyboard.release(this.onKeyDown),this.domElement.remove()}}),SL("components").ThemeOptions=Class.extend({init:function(t){if(!t.container)throw"Cannot build theme options without container";if(!t.model)throw"Cannot build theme options without model";this.config=$.extend({center:!0,rollingLinks:!0,resolution:!1,supportsCustomFonts:!1,colors:SL.config.THEME_COLORS,fonts:SL.config.THEME_FONTS,transitions:SL.config.THEME_TRANSITIONS,backgroundTransitions:SL.config.THEME_BACKGROUND_TRANSITIONS},t),this.theme=t.model,this.changed=new signals.Signal,this.render(),this.updateSelection(),this.toggleDeprecatedOptions(),this.scrollToTop(),this.loadFonts()},render:function(){this.domElement=$('<div class="sl-themeoptions">').appendTo(this.config.container),"string"==typeof this.config.className&&this.domElement.addClass(this.config.className),this.config.themes&&this.renderThemes(),(this.config.center||this.config.rollingLinks)&&this.renderOptions(),this.config.resolution&&this.renderResolution(),this.config.colors&&this.renderColors(),this.config.fonts&&this.renderFonts(),this.config.transitions&&this.renderTransitions(),this.config.backgroundTransitions&&this.renderBackgroundTransitions()},renderThemes:function(){if(this.config.themes&&!this.config.themes.isEmpty()){var t=$('<div class="section selector theme"><h3 class="section-heading">Theme</h3><ul></ul></div>').appendTo(this.domElement),e=t.find("ul");if(SL.current_user.isEnterpriseManager()){var i="Create and manage presentation themes that the whole team has access to.",n=SL.routes.THEME_EDITOR;t.find(".section-heading").append('<a href="'+n+'" class="info-link" data-tooltip="'+i+'" data-tooltip-maxwidth="240">Edit themes</a>')}e.append(['<li data-theme="" class="custom">','<span class="thumb-icon icon i-equalizer"></span>','<span class="thumb-label">Custom</span>',"</li>"].join("")),this.config.themes.forEach(function(t){var i=$('<li data-theme="'+t.get("id")+'"><span class="thumb-label" title="'+t.get("name")+'">'+t.get("name")+"</span></li>").appendTo(e);t.hasThumbnail()&&i.css("background-image",'url("'+t.get("thumbnail_url")+'")')});for(var s=e.get(0).childNodes.length,o=4,a=Math.ceil(s/o)*o-s,r=0;r<a;r++)e.append('<li class="filler"></li>');this.domElement.find(".theme li").on("vclick",this.onThemeClicked.bind(this))}},renderOptions:function(){var t=$('<div class="section options"><h3>Options</h3></div>').appendTo(this.domElement),e=$('<div class="options"></div>').appendTo(t);this.config.center&&(e.append('<div class="unit sl-checkbox outline"><input id="theme-center" value="center" type="checkbox"><label for="theme-center" data-tooltip="Center slide contents vertically (not visible while editing)" data-tooltip-maxwidth="220" data-tooltip-delay="500">Vertical centering</label></div>'),t.find("#theme-center").on("change",this.onOptionChanged.bind(this))),this.config.rollingLinks&&(e.append('<div class="unit sl-checkbox outline"><input id="theme-rolling_links" value="rolling_links" type="checkbox"><label for="theme-rolling_links" data-tooltip="Use a 3D hover effect on links" data-tooltip-maxwidth="220" data-tooltip-delay="500">Rolling links</label></div>'),t.find("#theme-rolling_links").on("change",this.onOptionChanged.bind(this)))},renderResolution:function(){var t=$('<div class="section resolution"><h3>Presentation Size</h3></div>').appendTo(this.domElement);this.resolutionInput=new SL.components.Resolution({values:SL.config.SLIDE_SIZES}),this.resolutionInput.domElement.appendTo(t),this.resolutionInput.changed.add(this.onResolutionChanged.bind(this))},renderColors:function(){var t=$('<div class="section selector color"><h3>Color</h3><ul></ul></div>').appendTo(this.domElement),e=t.find("ul");this.config.colors.forEach(function(t){var i=$('<li data-color="'+t.id+'"><div class="theme-body-color-block"></div><div class="theme-link-color-block"></div></li>');i.addClass("theme-color-"+t.id),i.addClass("themed"),i.appendTo(e),t.tooltip&&i.attr({"data-tooltip":t.tooltip,"data-tooltip-delay":250,"data-tooltip-maxwidth":300}),!SL.current_user.isPaid()&&t.pro&&i.attr("data-pro","true")}.bind(this)),this.domElement.find(".color li").on("vclick",this.onColorClicked.bind(this))},renderFonts:function(){var t=$('<div class="section selector font"><h3 class="section-heading">Typography</h3><ul></ul></div>').appendTo(this.domElement),e=t.find("ul");if(this.config.supportsCustomFonts){var i="You can use custom fonts from Typekit, Google or your own host. Click to learn more.",n="http://help.slides.com/knowledgebase/articles/1077976";this.config.themeEditor&&(n="http://help.slides.com/knowledgebase/articles/590055-theme-editor-custom-font"),t.find(".section-heading").append('<a href="'+n+'" target="_blank" class="info-link" data-tooltip="'+i+'" data-tooltip-maxwidth="240">Custom fonts</a>')}this.config.fonts.forEach(function(t){var i=$('<li data-font="'+t.id+'" data-name="'+t.title+'"><div class="themed"><h1>'+t.title+"</h1><a>Type</a></div></li>");i.addClass("theme-font-"+t.id),i.appendTo(e),t.deprecated===!0&&i.addClass("deprecated"),t.tooltip&&i.attr({"data-tooltip":t.tooltip,"data-tooltip-delay":250,"data-tooltip-maxwidth":300})}.bind(this)),this.domElement.find(".font li").on("vclick",this.onFontClicked.bind(this))},renderTransitions:function(){var t=$('<div class="section selector transition"><h3>Transition</h3></div>').appendTo(this.domElement);this.transitionList=new SL.components.TransitionList({transitions:SL.config.THEME_TRANSITIONS,itemElementType:"li"}),this.transitionList.selectionChanged.add(this.onTransitionChanged.bind(this)),this.transitionList.appendTo(t)},renderBackgroundTransitions:function(){var t=$('<div class="section selector background-transition"></div>').appendTo(this.domElement);t.append('<h3>Background Transition <span class="icon i-info info-icon" data-tooltip="Background transitions apply when navigating to or from a slide that has a background image or color." data-tooltip-maxwidth="250"></span></h3>'),this.backgroundTransitionList=new SL.components.TransitionList({transitions:SL.config.THEME_BACKGROUND_TRANSITIONS,itemElementType:"li"}),this.backgroundTransitionList.selectionChanged.add(this.onBackgroundTransitionChanged.bind(this)),this.backgroundTransitionList.appendTo(t)},populate:function(t){t&&(this.theme=t,this.updateSelection(),this.toggleDeprecatedOptions(),this.scrollToTop())},scrollToTop:function(){this.domElement.scrollTop(0)},loadFonts:function(){setTimeout(function(){SL.fonts.fontactive.add(this.onFontLoaded.bind(this)),SL.fonts.fontinactive.add(this.onFontLoaded.bind(this)),SL.fonts.loadAll()}.bind(this),500)},onFontLoaded:function(){$(".font li[data-font]").each(function(t,e){e=$(e),SL.fonts.isPackageLoaded(e.attr("data-font"))&&e.addClass("font-loaded")}.bind(this))},updateSelection:function(){this.config.themes&&!this.config.themes.isEmpty()&&this.domElement.toggleClass("using-theme",this.theme.has("id")),this.config.resolution&&this.resolutionInput.setValue(this.theme.get("width"),this.theme.get("height")),this.config.center&&this.domElement.find("#theme-center").prop("checked",1==this.theme.get("center")),this.config.rollingLinks&&this.domElement.find("#theme-rolling_links").prop("checked",1==this.theme.get("rolling_links")),this.domElement.find(".theme li").removeClass("selected"),this.domElement.find(".theme li[data-theme="+this.theme.get("id")+"]").addClass("selected"),0!==this.domElement.find(".theme li.selected").length||this.theme.has("id")||this.domElement.find('.theme li[data-theme=""]').addClass("selected"),this.domElement.find(".color li").removeClass("selected"),this.domElement.find(".color li[data-color="+this.theme.get("color")+"]").addClass("selected"),this.domElement.find(".font li").removeClass("selected"),this.domElement.find(".font li[data-font="+this.theme.get("font")+"]").addClass("selected"),this.domElement.find(".font li").each(function(t,e){SL.util.html.removeClasses(e,function(t){return t.match(/^theme\-color\-/gi)}),$(e).addClass("theme-color-"+this.theme.get("color"))}.bind(this)),this.transitionList.setValue(this.theme.get("transition")),this.backgroundTransitionList.setValue(this.theme.get("background_transition"))},applySelection:function(){SL.helpers.ThemeController.paint(this.theme,{center:!1,js:!1})},toggleDeprecatedOptions:function(){this.domElement.find(".font .deprecated").toggle(this.theme.isFontDeprecated()),this.domElement.find(".transition .deprecated").toggle(this.theme.isTransitionDeprecated()),this.domElement.find(".background-transition .deprecated").toggle(this.theme.isBackgroundTransitionDeprecated())},getTheme:function(){return this.theme},onThemeClicked:function(t){var e=$(t.currentTarget),i=e.data("theme");if(i){var n=this.config.themes.getByProperties({id:i});if(n){if(!n.isLoading()){var s=$('<div class="thumb-preloader hidden"><div class="spinner centered"></div></div>').appendTo(e),o=setTimeout(function(){s.removeClass("hidden")},1);SL.util.html.generateSpinners(),e.addClass("selected"),n.load().done(function(){this.theme=n.clone(),this.theme.loadCustomFonts(),this.updateSelection(),this.applySelection(),this.changed.dispatch()}.bind(this)).fail(function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative"),e.removeClass("selected")}.bind(this)).always(function(){clearTimeout(o),s.remove()}.bind(this))}}else SL.notify("Could not find theme data","negative")}else this.theme.set("id",null),this.theme.set("js",null),this.theme.set("css",null),this.theme.set("less",null),this.theme.set("html",null),this.updateSelection(),this.applySelection(),this.changed.dispatch();SL.analytics.trackTheming("Theme option selected")},onOptionChanged:function(){this.theme.set("center",this.domElement.find("#theme-center").is(":checked")),this.theme.set("rolling_links",this.domElement.find("#theme-rolling_links").is(":checked")),this.updateSelection(),this.applySelection(),this.changed.dispatch()},onResolutionChanged:function(){var t=this.resolutionInput.getValue();this.theme.set("width",t.width),this.theme.set("height",t.height),this.applySelection(),this.changed.dispatch()},onColorClicked:function(t){return t.preventDefault(),$(t.currentTarget).is("[data-pro]")?void window.open("/pricing"):(this.theme.set("color",$(t.currentTarget).data("color")),this.updateSelection(),this.applySelection(),SL.analytics.trackTheming("Color option selected",this.theme.get("color")),void this.changed.dispatch())},onFontClicked:function(t){t.preventDefault(),this.theme.set("font",$(t.currentTarget).data("font")),this.updateSelection(),this.applySelection(),SL.analytics.trackTheming("Font option selected",this.theme.get("font")),this.changed.dispatch()},onTransitionChanged:function(t){this.theme.set("transition",t),this.updateSelection(),this.applySelection(),SL.analytics.trackTheming("Transition option selected",this.theme.get("transition")),this.changed.dispatch()},onBackgroundTransitionChanged:function(t){event.preventDefault(),this.theme.set("background_transition",t),this.updateSelection(),this.applySelection(),SL.analytics.trackTheming("Background transition option selected",this.theme.get("background_transition")),this.changed.dispatch()},destroy:function(){this.resolutionInput&&(this.resolutionInput.destroy(),this.resolutionInput=null),this.changed.dispose(),this.domElement.remove(),this.theme=null,this.config=null}}),SL.tooltip=function(){function t(){a=$("<div>").addClass("sl-tooltip"),r=$('<p class="sl-tooltip-inner">').appendTo(a),l=$('<div class="sl-tooltip-arrow">').appendTo(a),d=$('<div class="sl-tooltip-arrow-fill">').appendTo(l),e()}function e(){n=n.bind(this),$(document).on("keydown vmousedown",function(){SL.tooltip.hide()}),SL.util.device.IS_PHONE||SL.util.device.IS_TABLET||($(document.body).delegate("[data-tooltip]","mouseenter",function(t){var e=$(t.currentTarget);if(!e.is("[no-tooltip]")){var n=e.attr("data-tooltip"),s=e.attr("data-tooltip-delay"),o=e.attr("data-tooltip-align"),a=e.attr("data-tooltip-alignment"),r=e.attr("data-tooltip-maxwidth"),l=e.attr("data-tooltip-maxheight"),d=e.attr("data-tooltip-ox"),c=e.attr("data-tooltip-oy"),h=e.attr("data-tooltip-x"),u=e.attr("data-tooltip-y");if(n){var p={anchor:e,align:o,alignment:a,delay:parseInt(s,10),maxwidth:parseInt(r,10),maxheight:parseInt(l,10)};d&&(p.ox=parseFloat(d)),c&&(p.oy=parseFloat(c)),h&&u&&(p.x=parseFloat(h),p.y=parseFloat(u),p.anchor=null),i(n,p)}}}),$(document.body).delegate("[data-tooltip]","mouseleave",s))}function i(t,e){if(!SL.util.device.IS_PHONE&&!SL.util.device.IS_TABLET){c=e||{},clearTimeout(p);var s=Date.now()-m;if("number"==typeof c.delay&&s>500)return p=setTimeout(i.bind(this,t,c),c.delay),void delete c.delay;a.css("opacity",0),a.appendTo(document.body),r.html(t),a.css({left:0,top:0,"max-width":c.maxwidth?c.maxwidth:"","max-height":c.maxheight?c.maxheight:""}),c.align&&a.css("text-align",c.align),n(),a.stop(!0,!0).animate({opacity:1},{duration:150}),$(window).on("resize scroll",n),$(c.anchor).parents(".sl-scrollable").on("scroll",n)}}function n(){var t=$(c.anchor);if(t.length){var e=c.alignment||"auto",i=10,n=t.get(0).getBoundingClientRect(),s=r.outerWidth(),o=r.outerHeight(),d=n.left,p=n.top,m=s/2,f=o/2;switch("number"==typeof c.ox&&(d+=c.ox),"number"==typeof c.oy&&(p+=c.oy),"auto"===e&&(e=n.top-(o+i+h)<0?"b":"t"),"rl"===e&&(e=n.right+(s+i+h)>window.innerWidth?"l":"r"),e){case"t":d+=(n.width-s)/2,p-=o+h+u;break;case"b":d+=(n.width-s)/2,p+=n.height+h+u;break;case"l":d-=s+h+u,p+=(n.height-o)/2;break;case"r":d+=n.width+h+u,p+=(n.height-o)/2}d=Math.min(Math.max(d,i),window.innerWidth-s-i),p=Math.min(Math.max(p,i),window.innerHeight-o-i);var g=h+3;switch(e){case"t":m=n.left-d+n.width/2,f=o,m=Math.min(Math.max(m,g),s-g);break;case"b":m=n.left-d+n.width/2,f=-h,m=Math.min(Math.max(m,g),s-g);break;case"l":m=s,f=n.top-p+n.height/2,f=Math.min(Math.max(f,g),o-g);break;case"r":m=-h,f=n.top-p+n.height/2,f=Math.min(Math.max(f,g),o-g)}l.css({left:Math.round(m),top:Math.round(f)}),a.css({left:Math.round(d),top:Math.round(p)}).attr("data-alignment",e)}}function s(){o()&&(m=Date.now()),clearTimeout(p),a.remove().stop(!0,!0),$(window).off("resize scroll",n),c&&$(c.anchor).parents(".sl-scrollable").off("scroll",n)}function o(){return a.parent().length>0}var a,r,l,d,c,h=6,u=4,p=-1,m=-1;return t(),{show:function(t,e){i(t,e)},hide:function(){s()},isVisible:function(){return o()},anchorTo:function(t,e,i){var n={};"undefined"!=typeof e&&(n["data-tooltip"]=e),"number"==typeof i.delay&&(n["data-tooltip-delay"]=i.delay),"string"==typeof i.alignment&&(n["data-tooltip-alignment"]=i.alignment),$(t).attr(n)}}}(),SL("components").TransitionList=Class.extend({init:function(t){this.config=$.extend({transitions:SL.config.THEME_TRANSITIONS,itemElementType:"button",defaultTransitionID:null,removeDeprecated:!1},t),this.selectionChanged=new signals.Signal,this.render(),this.bind()},render:function(){this.domElement=$('<div class="sl-transition-list"></div>'),this.config.transitions.forEach(function(t){this.config.removeDeprecated&&t.deprecated||this.renderTransitionItem(t)}.bind(this))},renderTransitionItem:function(t){var e={};e.wrapper=document.createElement(this.config.itemElementType),e.wrapper.classList.add("sl-transition-thumbnail"),e.wrapper.setAttribute("data-transition",t.id),e.thumb=document.createElement("div"),e.thumb.classList.add("thumb"),e.wrapper.appendChild(e.thumb),e.label=document.createElement("p"),e.label.classList.add("label"),e.label.textContent=t.title,e.wrapper.appendChild(e.label),t.deprecated===!0&&e.wrapper.classList.add("deprecated"),"string"==typeof this.config.defaultTransitionID&&this.config.defaultTransitionID===t.id&&(e.label.innerHTML+='<span class="icon i-star" data-tooltip="This is the default transition"></span>'),e.thumb.innerHTML='<div class="slide1"><span class="slide-number">1</span></div><div class="slide2"><span class="slide-number">2</span></div>',this.domElement.append(e.wrapper);var i=t.id;"default"===i&&(i="convex"),"linear"===i&&(i="slide");var n=SL.components.TransitionList.ANIMATIONS[i];n&&(e.wrapper.addEventListener("mouseenter",this.nextAnimationStep.bind(this,e)),e.wrapper.addEventListener("mouseleave",this.stopAnimation.bind(this,e)),e.animation=n,e.animationStep=0,e.transition=t,this.resetAnimation(e))},bind:function(){this.domElement.on("vclick",".sl-transition-thumbnail",function(t){this.setValue(t.currentTarget.getAttribute("data-transition"),!0)}.bind(this))},appendTo:function(t){this.domElement.appendTo(t)},nextAnimationStep:function(t){var e=this.setAnimationState(t,t.animationStep,1);clearTimeout(t.animationTimeout),t.animationTimeout=setTimeout(this.nextAnimationStep.bind(this,t),e.delay||700)},stopAnimation:function(t){clearTimeout(t.animationTimeout),this.resetAnimation(t)},resetAnimation:function(t){t.slide1Count=1,t.slide2Count=2,this.setAnimationState(t,0)},setAnimationState:function(t,e,i){"number"==typeof i&&(e=(e+i)%t.animation.length,e=Math.max(e,1));var n=t.animation[e];return n&&(t.animationStep=e,t.slide1||(t.slide1=t.thumb.querySelector(".slide1")),t.slide2||(t.slide2=t.thumb.querySelector(".slide2")),t.slide1Number||(t.slide1Number=t.thumb.querySelector(".slide1 .slide-number")),t.slide2Number||(t.slide2Number=t.thumb.querySelector(".slide2 .slide-number")),this.setAnimationStyles(t.slide1,n.slide1),this.setAnimationStyles(t.slide2,n.slide2),n.slide1&&n.slide1.increment&&(t.slide1Count+=2),n.slide2&&n.slide2.increment&&(t.slide2Count+=2),t.slide1Number.textContent=t.slide1Count>=100?"\ud83d\udea8\ud83d\udcaf\ud83d\udea8":t.slide1Count,t.slide2Number.textContent=t.slide2Count>=100?"\ud83d\udea8\ud83d\udcaf\ud83d\udea8":t.slide2Count),n},setAnimationStyles:function(t,e){if(e)for(var i in e)t.style[i]=e[i]},setValue:function(t,e){var i=this.getValue();i!==t&&(this.domElement.find(".sl-transition-thumbnail.selected").removeClass("selected"),this.domElement.find('.sl-transition-thumbnail[data-transition="'+t+'"]').addClass("selected"),e&&this.selectionChanged.dispatch(t))},getValue:function(){return this.domElement.find(".sl-transition-thumbnail.selected").attr("data-transition")},destroy:function(){this.selectionChanged&&(this.selectionChanged.dispose(),this.selectionChanged=null),this.config=null,this.domElement.remove()}}),SL.components.TransitionList.ANIMATIONS={slide:[{initial:!0,slide1:{opacity:1,transform:"translateX(-52%)"},slide2:{opacity:.5,transform:"translateX(52%)"}},{slide1:{opacity:0,transform:"translateX(-105%)"},slide2:{opacity:1,transform:"translateX(0%)"}},{delay:0,slide1:{opacity:0,transform:"translateX(105%)",increment:!0}},{slide1:{opacity:1,transform:"translateX(0%)"},slide2:{opacity:0,transform:"translateX(-105%)"}},{delay:0,slide2:{opacity:0,transform:"translateX(105%)",increment:!0}}],convex:[{initial:!0,slide1:{opacity:1,transform:"translateX(-52%) rotateY(-45deg)",transformOrigin:"100% 50%"},slide2:{opacity:.5,transform:"translateX(52%) rotateY(45deg)",transformOrigin:"0% 50%"}},{slide1:{opacity:0,transform:"translateX(-105%) rotateY(-75deg)"},slide2:{opacity:1,transform:"translateX(0%)"}},{delay:0,slide1:{opacity:0,transform:"translateX(105%) rotateY(75deg)",transformOrigin:"0% 50%",increment:!0},slide2:{opacity:1,transform:"translateX(0%)",transformOrigin:"100% 50%"}},{slide1:{opacity:1,transform:"translateX(0%)"},slide2:{opacity:0,transform:"translateX(-105%) rotateY(-75deg)"}},{delay:0,slide1:{opacity:1,transform:"translateX(0%)",transformOrigin:"100% 50%"},slide2:{opacity:0,transform:"translateX(105%) rotateY(75deg)",transformOrigin:"0% 50%",increment:!0}}],concave:[{initial:!0,slide1:{opacity:1,transform:"translateX(-52%) rotateY(45deg)",transformOrigin:"100% 50%"},slide2:{opacity:.5,transform:"translateX(52%) rotateY(-45deg)",transformOrigin:"0% 50%"}},{slide1:{opacity:0,transform:"translateX(-105%) rotateY(75deg)"},slide2:{opacity:1,transform:"translateX(0%)"}},{delay:0,slide1:{opacity:0,transform:"translateX(105%) rotateY(-75deg)",transformOrigin:"0% 50%",increment:!0},slide2:{opacity:1,transform:"translateX(0%)",transformOrigin:"100% 50%"}},{slide1:{opacity:1,transform:"translateX(0%)"},slide2:{opacity:0,transform:"translateX(-105%) rotateY(75deg)"}},{delay:0,slide1:{opacity:1,transform:"translateX(0%)",transformOrigin:"100% 50%"},slide2:{opacity:0,transform:"translateX(105%) rotateY(-75deg)",transformOrigin:"0% 50%",increment:!0}}],fade:[{initial:!0,slide1:{opacity:.5},slide2:{opacity:.5}},{slide1:{opacity:0},slide2:{opacity:1},delay:1e3},{slide1:{opacity:0,increment:!0},delay:0},{slide1:{opacity:1},slide2:{opacity:0},delay:1e3},{slide2:{opacity:0,increment:!0},delay:0}],none:[{initial:!0,slide1:{display:""},slide2:{display:"none"}},{slide1:{display:"none",increment:!0},slide2:{display:""},delay:1e3},{slide1:{display:""},slide2:{display:"none",increment:!0},delay:1e3}],zoom:[{initial:!0,slide1:{opacity:.3,transform:"scale(1.3)",zIndex:1},slide2:{opacity:1,transform:"scale(0.6)"}},{slide1:{opacity:0,transform:"scale(10)"},slide2:{opacity:1,transform:"scale(1)"}},{delay:0,slide1:{opacity:0,transform:"scale(0.1)",zIndex:"",increment:!0}},{slide1:{opacity:1,transform:"scale(1)"},slide2:{opacity:0,transform:"scale(10)"}},{delay:0,slide1:{opacity:1,transform:"scale(1)",zIndex:1},slide2:{opacity:0,transform:"scale(0.1)",increment:!0}}]},SL("components").Tutorial=Class.extend({init:function(t){this.options=$.extend({steps:[]},t),this.options.steps.forEach(function(t){"undefined"==typeof t.backwards&&(t.backwards=function(){}),"undefined"==typeof t.forwards&&(t.forwards=function(){})}),this.skipped=new signals.Signal,this.finished=new signals.Signal,this.index=-1,this.render(),this.bind(),this.layout(),this.paint(),this.controlsButtons.css("width",this.controlsButtons.outerWidth())},render:function(){this.domElement=$('<div class="sl-tutorial">'),this.domElement.appendTo(document.body),this.canvas=$('<canvas class="sl-tutorial-canvas">'),this.canvas.appendTo(this.domElement),this.canvas=this.canvas.get(0),this.context=this.canvas.getContext("2d"),this.controls=$('<div class="sl-tutorial-controls">'),this.controls.appendTo(this.domElement),this.controlsInner=$('<div class="sl-tutorial-controls-inner">'),this.controlsInner.appendTo(this.controls),this.renderPagination(),this.controlsButtons=$('<div class="sl-tutorial-buttons">'),this.controlsButtons.appendTo(this.controlsInner),
this.nextButton=$('<button class="button no-transition white l sl-tutorial-next">Next</button>'),this.nextButton.appendTo(this.controlsButtons),this.skipButton=$('<button class="button no-transition outline white l sl-tutorial-skip">Skip tutorial</button>'),this.skipButton.appendTo(this.controlsButtons),this.messageElement=$('<div class="sl-tutorial-message no-transition">').hide(),this.messageElement.appendTo(this.domElement)},renderPagination:function(){this.pagination=$('<div class="sl-tutorial-pagination">'),this.pagination.appendTo(this.controlsInner),this.options.steps.forEach(function(t,e){$('<li class="sl-tutorial-pagination-number">').appendTo(this.pagination).on("click",this.step.bind(this,e))}.bind(this))},updatePagination:function(){this.pagination.find(".sl-tutorial-pagination-number").each(function(t,e){e=$(e),e.toggleClass("past",t<this.index),e.toggleClass("present",t===this.index),e.toggleClass("future",t>this.index)}.bind(this))},bind:function(){this.onKeyDown=this.onKeyDown.bind(this),this.onSkipClicked=this.onSkipClicked.bind(this),this.onNextClicked=this.onNextClicked.bind(this),this.onWindowResize=this.onWindowResize.bind(this),SL.keyboard.keydown(this.onKeyDown),this.skipButton.on("click",this.onSkipClicked),this.nextButton.on("click",this.onNextClicked),$(window).on("resize",this.onWindowResize)},unbind:function(){SL.keyboard.release(this.onKeyDown),this.skipButton.off("click",this.onSkipClicked),this.nextButton.off("click",this.onNextClicked),$(window).off("resize",this.onWindowResize)},prev:function(){this.step(Math.max(this.index-1,0))},next:function(){this.index+1>=this.options.steps.length?(this.finished.dispatch(),this.destroy()):this.step(Math.min(this.index+1,this.options.steps.length-1))},step:function(t){if(this.index<t){for(;this.index<t;)this.index+=1,this.options.steps[this.index].forwards.call(this.options.context);this.index+1===this.options.steps.length&&(this.skipButton.hide(),this.nextButton.text("Get started"),this.domElement.addClass("last-step"))}else if(this.index>t){for(this.index+1===this.options.steps.length&&(this.skipButton.show(),this.nextButton.text("Next"),this.domElement.removeClass("last-step"));this.index>t;)this.options.steps[this.index].backwards.call(this.options.context),this.index-=1;this.options.steps[this.index].forwards.call(this.options.context)}this.updatePagination()},layout:function(){this.width=window.innerWidth,this.height=window.innerHeight;if(this.cutoutElement){var t=this.cutoutElement.offset();this.cutoutRect={x:t.left-this.cutoutPadding,y:t.top-this.cutoutPadding,width:this.cutoutElement.outerWidth()+2*this.cutoutPadding,height:this.cutoutElement.outerHeight()+2*this.cutoutPadding}}if(this.messageElement.is(":visible")){var e=20,i=this.messageElement.outerWidth(),n=this.messageElement.outerHeight(),s={left:(window.innerWidth-i)/2,top:(window.innerHeight-n)/2};if(this.messageOptions.anchor&&this.messageOptions.alignment){var o=this.messageOptions.anchor.offset(),a=this.messageOptions.anchor.outerWidth(),r=this.messageOptions.anchor.outerHeight();switch(this.messageOptions.alignment){case"t":s.left=o.left+(a-i)/2,s.top=o.top-n-e;break;case"r":s.left=o.left+a+e,s.top=o.top+(r-n)/2;break;case"b":s.left=o.left+(a-i)/2,s.top=o.top+r+e;break;case"l":s.left=o.left-i-e,s.top=o.top+(r-n)/2;break;case"tl":s.left=o.left-i-e,s.top=o.top-20}}s.left=Math.max(s.left,10),s.top=Math.max(s.top,10);var l="translate("+Math.round(s.left)+"px,"+Math.round(s.top)+"px)";this.messageElement.css({"-webkit-transform":l,"-moz-transform":l,"-ms-transform":l,transform:l}),setTimeout(function(){this.messageElement.removeClass("no-transition")}.bind(this),1)}},paint:function(){this.canvas.width=this.width,this.canvas.height=this.height,this.context.clearRect(0,0,this.width,this.height),this.context.fillStyle="rgba( 0, 0, 0, 0.7 )",this.context.fillRect(0,0,this.width,this.height),this.cutoutElement&&(this.context.clearRect(this.cutoutRect.x,this.cutoutRect.y,this.cutoutRect.width,this.cutoutRect.height),this.context.strokeStyle="#ddd",this.context.lineWidth=1,this.context.strokeRect(this.cutoutRect.x+.5,this.cutoutRect.y+.5,this.cutoutRect.width-1,this.cutoutRect.height-1))},cutout:function(t,e){e=e||{},this.cutoutElement=t,this.cutoutPadding=e.padding||0,this.layout(),this.paint()},clearCutout:function(){this.cutoutElement=null,this.cutoutPadding=0,this.paint()},message:function(t,e){this.messageOptions=$.extend({maxWidth:320,alignment:""},e),this.messageElement.html(t).show(),this.messageElement.css("max-width",this.messageOptions.maxWidth),this.messageElement.attr("data-alignment",this.messageOptions.alignment),this.layout(),this.paint()},clearMessage:function(){this.messageElement.hide(),this.messageOptions={}},hasNextStep:function(){return this.index+1<this.options.steps.length},destroy:function(){this.destroyed||(this.destroyed=!0,$(window).off("resize",this.onWindowResize),this.skipped.dispose(),this.finished.dispose(),this.unbind(),this.domElement.fadeOut(400,function(){this.remove()}))},onKeyDown:function(t){return 27===t.keyCode?(this.skipped.dispatch(),this.destroy(),!1):37===t.keyCode||8===t.keyCode?(this.prev(),!1):39!==t.keyCode&&32!==t.keyCode||(this.next(),!1)},onSkipClicked:function(){this.skipped.dispatch(),this.destroy()},onNextClicked:function(){this.next()},onWindowResize:function(){this.layout(),this.paint()}}),SL("views").Base=Class.extend({init:function(){this.header=new SL.components.Header,this.setupAce(),this.setupSocial(),this.setupPageNavigation(),this.setupCookieConsent(),this.setupMediaPreviews(),this.handleLogos(),this.handleOutlines(),this.handleFeedback(),this.handleWindowClose(),this.handleAutoRefresh(),this.parseTimes(),this.parseLinks(),this.parseMeters(),this.parseSpinners(),this.parseNotifications(),this.parseScrollLinks(),setInterval(this.parseTimes.bind(this),12e4)},setupAce:function(){"object"==typeof window.ace&&"object"==typeof window.ace.config&&"function"==typeof window.ace.config.set&&ace.config.set("workerPath","/ace")},setupSocial:function(){var t=$(".facebook-share-button"),e=$(".twitter-share-button"),i=t.length>0,n=e.length>0;if(i||n){var s={url:window.location.protocol+"//"+window.location.hostname+window.location.pathname,title:$('meta[property="og:title"]').attr("content"),description:$('meta[property="og:description"]').attr("content"),thumbnail:$('meta[property="og:image"]').attr("content")};i&&(t.attr("href",SL.util.social.getFacebookShareLink(s.url,s.title,s.description,s.thumbnail)),t.on("vclick",function(t){SL.util.openPopupWindow($(this).attr("href"),"Share on Facebook",600,400),t.preventDefault()})),n&&(e.attr("href",SL.util.social.getTwitterShareLink(s.url,s.title)),e.on("vclick",function(t){SL.util.openPopupWindow($(this).attr("href"),"Share on Twitter",600,400),t.preventDefault()}))}},setupPageNavigation:function(){function t(){c=a.find("li").toArray(),c=c.map(function(t){var e=t.querySelector("a"),i=document.getElementById(e.getAttribute("href").slice(1));return{listItem:t,anchor:e,target:i}}),c=c.filter(function(t){return!!t.target});var t,i=[];c.forEach(function(e,n){var s=e.anchor.offsetLeft,o=e.anchor.offsetTop,a=e.anchor.offsetHeight;0===n?(i.push("M",s,o,"L",s,o+a),e.pathStart=0):(t!==s&&i.push("L",t,o),i.push("L",s,o),d.setAttribute("d",i.join(" ")),e.pathStart=d.getTotalLength(),i.push("L",s,o+a)),t=s,d.setAttribute("d",i.join(" ")),e.pathEnd=d.getTotalLength()}),o=d.getTotalLength(),e()}function e(){var t=window.innerHeight,e=$(window).scrollTop();a.toggleClass("fixed",e>r);var i=o;pathEnd=0;var n=0;c.forEach(function(e){var s=e.target.getBoundingClientRect();s.bottom>t*h&&s.top<t*(1-u)?(i=Math.min(e.pathStart,i),pathEnd=Math.max(e.pathEnd,pathEnd),n+=1,e.listItem.classList.add("selected")):e.listItem.classList.remove("selected")}),n>0?(d.setAttribute("stroke-dashoffset","1"),d.setAttribute("stroke-dasharray","1, "+i+", "+(pathEnd-i)+", "+o),d.setAttribute("opacity",1)):d.setAttribute("opacity",0)}var i=$(".sl-scroll-target");if(i.length){var n=$(".sl-page-nav ul");i.each(function(){var t=this.hasAttribute("data-scroll-label")?this.getAttribute("data-scroll-label"):this.textContent;n.append('<li><a class="sl-scroll-anchor" href="#'+this.getAttribute("id")+'">'+t+"</a></li>")})}var s=$('.sl-scroll-anchor[href^="#"]');if(s.length){var o,a=$(".sl-page-nav"),r=a.position().top,l=$(['<svg class="sl-page-nav-marker" width="200" height="200" xmlns="http://www.w3.org/2000/svg">','<path stroke="#444" stroke-width="2" fill="transparent" stroke-dasharray="0, 0, 0, 1000" stroke-linecap="round" stroke-linejoin="round" />',"</svg>"].join("")).appendTo(a),d=l.find("path").get(0),c=[],h=.1,u=.2;$(window).on("resize",$.throttle(t.bind(this),100)),$(window).on("scroll",$.throttle(e.bind(this),100)),setTimeout(t,1)}},setupCookieConsent:function(){"development"===SL.config.APP_ENV||!window.cookieconsent||SL.util.user.isLoggedIn()||SL.routes.isDeckView()||(window.cookieconsent.initialise({container:document.body,location:!1,blacklistPage:[/^\/users\/(sign_up|invitations)/g,/^\/teams\/new/g,/.+\/(live|speaker|embed)$/g,/.+\/speaker/g],palette:{popup:{background:"rgba(255, 255, 255, 0.95)",text:"#252525"},button:{background:"#1BAEE1",text:"#fff"}},content:{message:"This website uses cookies to offer you a better browsing experience and personalize content. By continuing to use this site, you consent to our use of cookies.",href:SL.routes.SECURITY_COOKIES,dismiss:"Allow cookies"},cookie:{domain:"development"===SL.config.APP_ENV?"."+SL.config.APP_HOST:".slides.com"},dismissOnScroll:100,dismissOnTimeout:5e3,onStatusChange:function(){window.scrollY>100&&this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}),$(".cc-window").removeClass("cc-floating").addClass("cc-banner"))},setupMediaPreviews:function(){$("[data-preview-media]").each(function(t,e){e=$(e);var i=e.attr("data-preview-media"),n=/\.mp4/.test(i)?"video":"image",s=parseInt(e.attr("data-preview-media-width"),10),o=parseInt(e.attr("data-preview-media-height"),10);e.on("vclick",function(){SL.popup.openOne(SL.components.popup.PreviewMedia,{mediaType:n,mediaURL:i,mediaWidth:s,mediaHeight:o,titleItem:e.attr("data-preview-title")||"Preview"})}.bind(this)),SL.promptOnHover(e,{anchor:e,mediaType:n,mediaURL:i,mediaWidth:s,mediaHeight:o},SL.components.prompts.PreviewMedia)})},handleLogos:function(){setTimeout(function(){$(".logo-animation").addClass("open")},600)},handleOutlines:function(){var t=$("<style>").appendTo("head").get(0),e=function(e){t.styleSheet?t.styleSheet.cssText=e:t.innerHTML=e};$(document).on("mousedown",function(){e("a, button, .sl-select, .sl-checkbox label, .radio label, .focus-outline { outline: none !important; }")}),$(document).on("keydown",function(){e("")})},handleFeedback:function(){$("html").on("click","[data-feedback-mode]",function(t){if(UserVoice&&"function"==typeof UserVoice.show){var e=$(this),i={target:this,mode:e.attr("data-feedback-mode")||"contact",position:e.attr("data-feedback-position")||"top",screenshot_enabled:e.attr("data-feedback-screenshot_enabled")||"true",smartvote_enabled:e.attr("data-feedback-smartvote-enabled")||"true",ticket_custom_fields:{}};SL.current_deck&&(i.ticket_custom_fields["Deck ID"]=SL.current_deck.get("id"),i.ticket_custom_fields["Deck Slug"]=SL.current_deck.get("slug"),i.ticket_custom_fields["Deck Version"]=SL.current_deck.get("version"),i.ticket_custom_fields["Deck Font"]=SL.current_deck.get("theme_font"),i.ticket_custom_fields["Deck Color"]=SL.current_deck.get("theme_color"),i.ticket_custom_fields["Deck Transition"]=SL.current_deck.get("transition"),i.ticket_custom_fields["Deck Background Transition"]=SL.current_deck.get("backgroundTransition"));var n=e.attr("data-feedback-type");n&&n.length&&(i.ticket_custom_fields.Type=n);var s=e.attr("data-feedback-contact-title");s&&s.length&&(i.contact_title=s),UserVoice.show(i),t.preventDefault()}})},handleWindowClose:function(){var t=SL.util.getQuery();if(t&&t.autoclose&&window.opener){var e=parseInt(t.autoclose,10)||0;setTimeout(function(){try{window.close()}catch(t){}},e)}},handleAutoRefresh:function(){var t=SL.util.getQuery();if(t&&t.autoRefresh){var e=parseInt(t.autoRefresh,10);!isNaN(e)&&e>0&&(e=Math.max(e,1e4),setTimeout(function(){window.Reveal&&window.Reveal.isReady()&&window.Reveal.configure({autoSlide:0}),window.location.reload()},e))}},parseTimes:function(){$("time.ago").each(function(){var t=$(this).attr("datetime");t&&$(this).text(moment.utc(t).fromNow())}),$("time.date").each(function(){var t=$(this).attr("datetime");t&&$(this).text(moment.utc(t).format("MMM Do, YYYY"))})},parseLinks:function(){$(".linkify").each(function(){$(this).html(SL.util.string.linkify($(this).text()))})},parseMeters:function(){$(".sl-meter").each(function(){var t=$(this);new SL.components.Meter(t,{type:t.attr("data-type"),value:parseInt(t.attr("data-value"),10),total:parseInt(t.attr("data-total"),10)})})},parseSpinners:function(){SL.util.html.generateSpinners()},parseNotifications:function(){$(".flash-notification").each(function(){var t=$(this),e=t.attr("data-notification-type");"persistent"===e?SL.notify(t.remove().text(),{optional:!1,buttons:[{label:"OK"}]}):"confirmation"===e?SL.prompt({type:"flashmessage",title:t.remove().text(),overlayOpacity:.9}):SL.notify(t.remove().text(),e)})},parseScrollLinks:function(){$(document).delegate("a[data-scroll-to]","click",function(t){var e=t.currentTarget,i=$(e.getAttribute("href")),n=parseInt(e.getAttribute("data-scroll-to-offset"),10),s=parseInt(e.getAttribute("data-scroll-to-duration"),10);isNaN(n)&&(n=-20),isNaN(s)&&(s=1e3),i.length&&$("html, body").animate({scrollTop:i.offset().top+n},s),t.preventDefault()})}}),SL("views.decks").PresentBase=SL.views.Base.extend({init:function(t){this._super(),this.options=$.extend({startPresentationLabel:"Start presenting",startPresentationShortcut:SL.util.getKeyboardShortcutName("P",{meta:!0}),editDeckShortcut:SL.util.getKeyboardShortcutName("E",{meta:!0}),editDeckURL:SL.routes.DECK_EDIT(SL.current_user.get("username"),SL.current_deck.get("slug"))},t),this.setupReveal(),Reveal.isReady()?this.setup():(SL.helpers.PageLoader.show(),Reveal.addEventListener("ready",this.setup.bind(this)))},setupReveal:function(){SL.util.setupReveal(this.getRevealConfig())},setup:function(){SL.helpers.PageLoader.waitForFonts(),this.render(),this.bind(),this.syncPresentOptions(),SL.keyboard.keydown(this.onDocumentKeydown.bind(this))},render:function(){this.presentationControls=$(['<div class="sl-present-controls">','<div class="sl-present-controls-content">',"</div>",'<footer class="sl-present-controls-footer">','<button class="button xl positive start-presentation" data-tooltip="'+this.options.startPresentationShortcut+'">'+this.options.startPresentationLabel+"</button>","</footer>","</div>"].join("")).appendTo(document.body),this.presentationControlsContent=this.presentationControls.find(".sl-present-controls-content"),this.presentationControlsFooter=this.presentationControls.find(".sl-present-controls-footer"),this.presentationControlsExpander=$(['<div class="sl-present-controls-expander" data-tooltip="Show menu ('+this.options.startPresentationShortcut+')" data-tooltip-alignment="r">','<span class="icon i-chevron-right"></span>',"</div>"].join("")).appendTo(document.body),$(".global-header").prependTo(this.presentationControls),SL.helpers.Fullscreen.isEnabled()===!1&&this.presentationControls.find(".fullscreen-toggle").hide(),this.presentationControlsScrollShadow=new SL.components.ScrollShadow({parentElement:this.presentationControls,headerElement:this.presentationControls.find(".global-header"),contentElement:this.presentationControlsContent,footerElement:this.presentationControlsFooter})},bind:function(){this.presentationControls.find(".edit-button").on("vclick",this.onEditButtonClicked.bind(this)),this.presentationControls.find(".fullscreen-toggle").on("vclick",this.onFullscreenToggled.bind(this)),this.presentationControls.find(".button.start-presentation").on("vclick",this.startPresentation.bind(this)),this.presentationControlsExpander.on("vclick",this.stopPresentation.bind(this)),$(document).on("mousemove",this.onMouseMove.bind(this)),$(document).on("mouseleave",this.onMouseLeave.bind(this)),$(document).on("webkitfullscreenchange mozfullscreenchange MSFullscreenChange fullscreenchange",this.onFullscreenChange.bind(this))},syncPresentOptions:function(){this.presentationControls.find(".fullscreen-toggle input").prop("checked",SL.helpers.Fullscreen.isActive())},startPresentation:function(){$("html").addClass("presentation-started"),this.presentationStarted=!0,this.syncPresentOptions(),this.highlightPresentationExpander(),setTimeout(function(){$("html").addClass("presentation-started-transition-ended")}.bind(this),500)},stopPresentation:function(){$("html").removeClass("presentation-started presentation-started-transition-ended"),this.presentationStarted=!1,this.syncPresentOptions(),this.presentationControlsExpander.removeClass("visible")},hasStartedPresentation:function(){return!!this.presentationStarted},highlightPresentationExpander:function(){setTimeout(function(){this.presentationControlsExpander.addClass("highlight"),setTimeout(function(){this.presentationControlsExpander.removeClass("highlight")}.bind(this),2e3)}.bind(this),400)},getRevealConfig:function(){return{hash:!0,controlsTutorial:!1,controlsBackArrows:"visible",hideInactiveCursor:!0,openLinksInTabs:!0,trackEvents:!0,embedded:!0}},getEditorURL:function(){var t=this.options.editDeckURL,e=Reveal.getIndices();return t+="#/"+e.h,"number"==typeof e.v&&e.v>0&&(t+="/"+e.v),t},onFullscreenToggled:function(t){t.preventDefault(),SL.helpers.Fullscreen.toggle()},onFullscreenChange:function(){this.syncPresentOptions(),Reveal.layout()},onEditButtonClicked:function(t){t.preventDefault(),window.location=this.getEditorURL()},onMouseMove:function(t){this.presentationControlsExpander.toggleClass("visible",this.hasStartedPresentation()&&t.clientX<40)},onMouseLeave:function(){this.presentationControlsExpander.removeClass("visible")},onDocumentKeydown:function(t){return"e"===t.key&&(t.ctrlKey||t.metaKey)?(window.location=this.getEditorURL(),!1):"p"!==t.key||!t.ctrlKey&&!t.metaKey||(this.hasStartedPresentation()?this.stopPresentation():this.startPresentation(),!1)}}),SL("views.decks").EditRequiresUpgrade=SL.views.Base.extend({init:function(){this._super(),this.makePublicButton=$(".make-deck-public").first(),this.makePublicButton.on("click",this.onMakePublicClicked.bind(this)),this.makePublicLoader=Ladda.create(this.makePublicButton.get(0))},makeDeckPublic:function(){var t={type:"POST",url:SL.endpoints.PUBLISH_DECK(SL.current_deck.get("id")),context:this,data:{visibility:SL.models.Deck.VISIBILITY_ALL}};this.makePublicLoader.start(),$.ajax(t).done(function(){window.location=SL.routes.DECK_EDIT(SL.current_user.get("username"),SL.current_deck.get("slug"))}).fail(function(){SL.notify(SL.locale.get("DECK_VISIBILITY_CHANGED_ERROR"),"negative"),this.makePublicLoader.stop()})},onMakePublicClicked:function(t){t.preventDefault(),this.makeDeckPublic()}}),SL("views.decks").Embed=SL.views.Base.extend({init:function(){this._super(),this.footerElement=$(".embed-footer"),this.shareButton=this.footerElement.find(".embed-footer-share"),this.revealElement=$(".reveal"),SL.util.setupReveal({embedded:!0,preventMediaDownloads:!0,openLinksInTabs:!0,trackEvents:!0,maxScale:SL.config.PRESENT_UPSIZING_MAX_SCALE}),$(window).on("resize",this.layout.bind(this)),$(document).on("webkitfullscreenchange mozfullscreenchange MSFullscreenChange fullscreenchange",this.layout.bind(this)),this.shareButton.on("click",this.onShareClicked.bind(this)),this.readQuery(),this.setupFullscreen(),this.layout()},readQuery:function(){var t=SL.util.getQuery(),e=t.style;"hidden"!==e||SL.current_deck.isPaid()||(e=null),e&&$("html").attr("data-embed-style",e),"hidden"===t.byline&&SL.current_deck.isPaid()&&$("html").attr("data-embed-byline","hidden"),"hidden"===t.share&&SL.current_deck.isPaid()&&$("html").attr("data-embed-share","hidden")},setupFullscreen:function(){Modernizr.fullscreen===!0&&(this.footerElement.find(".embed-footer-fullscreen").removeAttr("href").changeElementType("button"),this.footerElement.find(".embed-footer-fullscreen").on("click",this.onFullscreenClicked.bind(this)))},layout:function(){this.footerElement.is(":visible")?this.revealElement.height(window.innerHeight-this.footerElement.height()):this.revealElement.height("100%"),Reveal.layout()},onFullscreenClicked:function(){var t=$("html").get(0);if(t)return SL.helpers.Fullscreen.enter(t),!1},onShareClicked:function(){SL.popup.open(SL.components.decksharer.DeckSharer,{deck:SL.current_deck}),SL.analytics.trackPresenting("Share clicked (embed footer)")}}),SL("views.decks").Export=Class.extend({init:function(){SL.deck.util.injectNotes(),SL.deck.util.renderMath(),SL.deck.util.injectCodeCopyButtons(),window.Reveal&&Reveal.isReady()&&(Reveal.sync(),Reveal.layout())}}),SL("views.decks").Fullscreen=SL.views.Base.extend({init:function(){this._super(),/no-autoplay=1/.test(window.location.search)&&($(".reveal [data-autoplay]").removeAttr("data-autoplay"),$(".reveal [data-background-video]").attr("data-background-video-muted",!0)),SL.util.isInIframe()&&this.setupSlideTemplateAPI(),Reveal.addEventListener("ready",function(){var t=SL.util.getQuery();if("string"==typeof t.jumpToSlideID){var e=document.querySelector('section[data-id="'+t.jumpToSlideID+'"]');e&&SL.util.deck.navigateToSlide(e)}}),SL.util.setupReveal({preventMediaDownloads:!0,hideInactiveCursor:!0,openLinksInTabs:!0,trackEvents:!0,maxScale:SL.config.PRESENT_UPSIZING_MAX_SCALE})},setupSlideTemplateAPI:function(){SL.deck.util.injectNotes(),$(".reveal section").each(function(){this.originalSlideHTML=this.outerHTML}),window.addEventListener("message",function(t){var e=SL.util.parseJSON(t.data);"slides"===e.namespace&&"publish-current-slide-html"===e.eventName&&window.parent.postMessage(JSON.stringify({namespace:"slides",eventName:"insert-slide",data:Reveal.getCurrentSlide().originalSlideHTML}),"*")})}}),SL("views.decks").Kiosk=SL.views.decks.PresentBase.extend({init:function(){this.defaultOptions={autoSlide:SL.config.KIOSK_AUTOSLIDE_DEFAULT,controls:!1,progress:!1,slideNumber:!1,autoSlideStoppable:!1},this._super({startPresentationLabel:"Start",minAutoSlideSeconds:2,maxAutoSlideSeconds:180})},setup:function(){this._super.apply(this,arguments),SL.util.user.isLoggedInDeckOwner()&&this.checkDeckVersion(),Reveal.getQueryHash().started?this.startPresentation():Reveal.toggleAutoSlide(!1)},render:function(){this._super.apply(this,arguments),this.presentationControlsContent.append(["<h2>Kiosk Mode</h2>",'<p class="description">This view automatically steps through a looped version of your deck and is particularly useful for digital signage. Changes made to the deck are automatically loaded at a 5min interval.</p>','<div class="sl-present-controls-section sl-form autoslide-section">',"<h2>Auto-Slide Time</h2>",'<p>The interval between slide changes. This value can be <a href="https://help.slides.com/knowledgebase/articles/1902748" target="_blank">customized for specific slides</a>.</p>',"</div>",'<div class="sl-present-controls-section sl-form">',"<h2>Options</h2>",'<div class="sl-checkbox flush-left fullscreen-toggle">','<input id="fullscreen-checkbox" type="checkbox">','<label for="fullscreen-checkbox">Fullscreen</label>',"</div>",'<div class="sl-checkbox flush-left controls-toggle">','<input id="controls-checkbox" type="checkbox">','<label for="controls-checkbox">Show presentation controls</label>',"</div>",'<div class="sl-checkbox flush-left stoppable-toggle">','<input id="stoppable-checkbox" type="checkbox">','<label for="stoppable-checkbox">Allow auto-sliding to be paused</label>',"</div>","</div>"].join("")),this.autoSlideInput=new SL.components.Range({minValue:this.options.minAutoSlideSeconds,maxValue:this.options.maxAutoSlideSeconds,unit:"s",width:"100%"}),this.autoSlideInput.appendTo(this.presentationControlsContent.find(".autoslide-section")),this.autoSlideInput.changed.add(this.writeOptionsToURL.bind(this)),$('<a class="button xl light-grey edit-button" href="'+this.options.editDeckURL+'" data-tooltip="Edit deck ('+this.options.editDeckShortcut+')"><span class="icon i-pen-alt2"></span></a>').prependTo(this.presentationControlsFooter),$('<button class="button xl light-grey deck-view-button" data-tooltip="'+SL.locale.get("OPEN_DECK_IN")+'"><span class="icon i-tv"></span></a>').prependTo(this.presentationControlsFooter),SL.util.user.isLoggedInDeckOwner()||this.presentationControls.find(".edit-button, .deck-view-button").hide()},bind:function(){this._super.apply(this,arguments),this.presentationControls.find(".controls-toggle").on("vclick",this.onControlsToggled.bind(this)),this.presentationControls.find(".stoppable-toggle").on("vclick",this.onStoppableToggled.bind(this)),this.presentationControls.find(".deck-view-button").on("vclick",this.onDeckViewClicked.bind(this))},checkDeckVersion:function(){$.ajax({url:SL.endpoints.GET_DECK_UPDATED_AT(SL.current_deck.get("id")),type:"GET",context:this}).done(function(t){if(t&&"string"==typeof t.updated_at){var e=new Date(t.updated_at).getTime();isNaN(e)||(this.currentDeckUpdatedAt?e>this.currentDeckUpdatedAt&&(this.currentDeckUpdatedAt=e,this.reloadDeck()):this.currentDeckUpdatedAt=e)}}).always(function(){setTimeout(this.checkDeckVersion.bind(this),SL.config.KIOSK_CHANGE_PING_INTERVAL)})},reloadDeck:function(){this.reloadDeckXHR&&this.reloadDeckXHR.abort();var t=SL.endpoints.GET_DECK_JSON(SL.current_deck.user.get("username"),SL.current_deck.get("slug"));SL.util.deck.reloadDeck(t,SL.current_deck).always(function(){this.reloadDeckXHR=null}.bind(this))},syncPresentOptions:function(){this._super.apply(this,arguments);var t=Reveal.getConfig(),e=Reveal.getQueryHash(),i=("number"==typeof e.autoSlide?e.autoSlide:this.defaultOptions.autoSlide)/1e3;this.presentationControls.find(".controls-toggle input").prop("checked",t.controls),this.presentationControls.find(".stoppable-toggle input").prop("checked",t.autoSlideStoppable),this.autoSlideInput.setValue(i)},startPresentation:function(){var t=1e3*(this.autoSlideInput.getValue()||this.defaultOptions.minAutoSlideSeconds);Reveal.configure({autoSlide:t}),Reveal.toggleAutoSlide(!0),this._super.apply(this,arguments),this.writeOptionsToURL()},stopPresentation:function(){Reveal.configure({autoSlide:0}),this._super.apply(this,arguments),this.writeOptionsToURL()},writeOptionsToURL:function(){var t=Reveal.getConfig(),e={};e.controls=t.controls,e.autoSlide=1e3*this.autoSlideInput.getValue(),e.autoSlideStoppable=t.autoSlideStoppable,e.controls===this.defaultOptions.controls&&delete e.controls,e.autoSlide===this.defaultOptions.autoSlide&&delete e.autoSlide,e.autoSlideStoppable===this.defaultOptions.autoSlideStoppable&&delete e.autoSlideStoppable,this.hasStartedPresentation()&&(e.started=!0);var i=[];for(var n in e)i.push(n+"="+e[n]);0===i.length?window.history.replaceState(null,null,window.location.pathname):window.history.replaceState(null,null,window.location.pathname+"?"+i.join("&"))},getRevealConfig:function(){return $.extend(this._super.apply(this,arguments),this.defaultOptions,{loop:!0,hash:!1})},onControlsToggled:function(t){t.preventDefault();var e=!Reveal.getConfig().controls;Reveal.configure({controls:e,progress:e,slideNumber:e&&SL.current_deck.get("slide_number")}),this.syncPresentOptions(),this.writeOptionsToURL()},onStoppableToggled:function(t){t.preventDefault();var e=!Reveal.getConfig().autoSlideStoppable;Reveal.configure({autoSlideStoppable:e}),this.syncPresentOptions(),this.writeOptionsToURL()},onDeckViewClicked:function(t){new SL.components.prompts.DeckView({anchor:$(t.currentTarget),editorURL:this.getEditorURL(),kioskURL:null}).show()}}),SL("views.decks").LiveClient=SL.views.Base.extend({init:function(){this._super(),SL.util.setupReveal({touch:!1,history:!1,keyboard:!1,controls:!1,progress:!1,showNotes:!1,slideNumber:!1,autoSlide:0,respondToHashChanges:!1,preventMediaDownloads:!0,openLinksInTabs:!0,trackEvents:!0}),this.stream=new SL.helpers.StreamLive({showErrors:!0}),this.stream.ready.add(this.onStreamReady.bind(this)),this.stream.stateChanged.add(this.onStreamStateChanged.bind(this)),this.stream.statusChanged.add(this.onStreamStatusChanged.bind(this)),this.pointer=new SL.components.StreamPointer({stream:this.stream}),this.render(),this.bind(),this.hideVideoControls(),this.showStartScreenIfNeeded(),Reveal.isReady()?this.setup():Reveal.addEventListener("ready",this.setup.bind(this))},setup:function(){this.syncPresentOptions(),this.stream.connect()},render:function(){var t=SL.current_deck.get("user"),e=SL.routes.DECK(t.username,SL.current_deck.get("slug")),i=t.thumbnail_url;this.summaryBubble=$(['<a class="summary-bubble hidden" href="'+e+'" target="_blank">','<div class="summary-bubble-picture" style="background-image: url('+i+')"></div>','<div class="summary-bubble-content"></div>',"</a>"].join("")).appendTo(document.body),this.summaryBubbleContent=this.summaryBubble.find(".summary-bubble-content"),this.renderUserSummary()},renderUserSummary:function(){var t=SL.current_deck.get("user");this.summaryBubbleContent.empty(),$("<h4></h4>").text(SL.current_deck.get("title")).appendTo(this.summaryBubbleContent),$("<p></p>").text("By "+(t.name||t.username)).appendTo(this.summaryBubbleContent)},renderWaitingSummary:function(){this.summaryBubbleContent.html(["<h4>Waiting for presenter</h4>",'<p class="retry-status"></p>'].join("")),this.summaryBubbleRetryStatus=this.summaryBubbleContent.find(".retry-status")},renderConnectionLostSummary:function(){this.summaryBubbleContent.html(["<h4>Connection lost</h4>","<p>Attempting to reconnect</p>"].join(""))},startUpdatingTimer:function(){var t=function(){if(this.summaryBubbleRetryStatus&&this.summaryBubbleRetryStatus.length){var t=Date.now()-this.stream.getRetryStartTime(),e=Math.ceil((SL.helpers.StreamLive.CONNECTION_RETRY_INTERVAL-t)/1e3);isNaN(e)?this.summaryBubbleRetryStatus.text("Retrying"):e>0?this.summaryBubbleRetryStatus.text("Retrying in "+e+"s"):this.summaryBubbleRetryStatus.text("Retrying now")}}.bind(this);clearInterval(this.updateTimerInterval),this.updateTimerInterval=setInterval(t,100),t()},stopUpdatingTimer:function(){clearInterval(this.updateTimerInterval)},hideVideoControls:function(){SL.util.device.IS_PHONE||$(".sl-block video[controls]").removeAttr("controls")},showStartScreenIfNeeded:function(){var t=$(".sl-start-screen"),e=SL.util.deck.hasMediaThatRequiresUserInteraction()&&!/skipStartScreen/i.test(window.location.search)&&!/altspacevr/i.test(navigator.userAgent);if(e){var i=document.createElement("video");i.setAttribute("src","https://static.slid.es/videos/empty-video.mp4"),t.addClass("visible"),t.on("vclick",function(){t.remove(),i.play(),i.pause()})}else t.remove()},syncPresentOptions:function(){var t=Reveal.getConfig(),e={showNotes:SL.current_deck.user_settings.get("present_notes"),slideNumber:SL.current_deck.user_settings.get("present_controls")&&SLConfig.deck.slide_number,maxScale:SL.current_deck.user_settings.get("present_upsizing")?SL.config.PRESENT_UPSIZING_MAX_SCALE:1};for(var i in e)if(e[i]!==t[i]){Reveal.configure(e);break}this.summaryBubble.toggleClass("hidden",!SL.current_deck.user_settings.get("present_controls")),this.pointer.setEnabled(SL.current_deck.user_settings.get("present_pointer"))},bind:function(){this.summaryBubble.on("mouseover",this.expandSummary.bind(this)),this.summaryBubble.on("mouseout",this.collapseSummary.bind(this))},expandSummary:function(t){clearTimeout(this.collapseSummaryTimeout);var e=window.innerWidth-(this.summaryBubbleContent.find("h4, p").offset().left+40);e=Math.min(e,400),this.summaryBubbleContent.find("h4, p").css("max-width",e),this.summaryBubble.width(this.summaryBubble.height()+this.summaryBubbleContent.outerWidth()),"number"==typeof t&&(this.collapseSummaryTimeout=setTimeout(this.collapseSummary.bind(this),t))},expandSummaryError:function(){this.summaryBubbleError=!0,this.expandSummary()},collapseSummary:function(){this.summaryBubbleError||(clearTimeout(this.collapseSummaryTimeout),this.summaryBubble.width(this.summaryBubble.height()))},onStreamReady:function(){this.expandSummary(5e3)},onStreamStateChanged:function(t){t&&("boolean"==typeof t.present_pointer&&SL.current_deck.user_settings.set("present_pointer",t.present_pointer),"boolean"==typeof t.present_controls&&SL.current_deck.user_settings.set("present_controls",t.present_controls),"boolean"==typeof t.present_notes&&SL.current_deck.user_settings.set("present_notes",t.present_notes),"boolean"==typeof t.present_upsizing&&SL.current_deck.user_settings.set("present_upsizing",t.present_upsizing),this.syncPresentOptions())},onStreamStatusChanged:function(t){t===SL.helpers.StreamLive.STATUS_WAITING_FOR_PUBLISHER?(this.renderWaitingSummary(),
this.expandSummaryError(),this.startUpdatingTimer()):(this.summaryBubbleError=!1,this.renderUserSummary(),this.stopUpdatingTimer())}}),SL("views.decks").LiveServer=SL.views.decks.PresentBase.extend({init:function(){this.canShareLiveLink=!0,this.canEdit=!0,this._super({liveViewHelpURL:"http://help.slides.com/knowledgebase/articles/333924",speakerViewHelpURL:"http://help.slides.com/knowledgebase/articles/333923",remoteControlHelpURL:"http://help.slides.com/knowledgebase/articles/333925-remote-control",speakerViewShortcut:SL.util.getKeyboardShortcutName("S",{meta:!0}),speakerViewURL:SL.current_deck.getURL({view:"speaker"})})},setup:function(){this.stream=new SL.helpers.StreamLive({publisher:!0,showErrors:!1}),this.stream.connect(),SL.util.device.IS_PHONE||SL.util.device.IS_TABLET||(this.pointer=new SL.components.StreamPointer({publisher:!0,stream:this.stream,hideDefault:!0})),this._super.apply(this,arguments)},render:function(){this._super.apply(this,arguments),this.presentationControlsContent.append(["<h2>Present View</h2>",'<div class="sl-present-controls-section">',"<h2>Speaker View</h2>",'<p>The control panel for your presentation where you can see speaker notes, elapsed time, an upcoming slide preview and more. <a href="'+this.options.speakerViewHelpURL+'" target="_blank">Learn more.</a></p>','<a class="button l light-grey" href="'+this.options.speakerViewURL+'" target="_blank" data-tooltip="'+this.options.speakerViewShortcut+'" data-tooltip-alignment="r">Open speaker view <span class="icon i-launch" style="margin-left: 6px;"</span></a>',"</div>",'<div class="sl-present-controls-section">',"<h2>Remote Control</h2>",'<p>View speaker notes and remote control the presentation from your phone. <a href="'+this.options.remoteControlHelpURL+'" target="_blank">Learn more.</a></p>','<button class="button l light-grey sms-link">Send SMS</button>',"</div>",'<div class="sl-present-controls-section live-section">',"<h2>Present Live</h2>",'<p class="live-description">Share this link with your audience to have them follow along with the presentation in real-time. <a href="'+this.options.liveViewHelpURL+'" target="_blank">Learn more.</a></p>','<div class="live-share"></div>',"</div>",'<div class="sl-present-controls-section sl-form">',"<h2>Options</h2>",'<div class="sl-checkbox flush-left fullscreen-toggle">','<input id="fullscreen-checkbox" type="checkbox">','<label for="fullscreen-checkbox">Fullscreen</label>',"</div>",'<div class="sl-checkbox flush-left pointer-toggle" data-tooltip="Allow viewers of a live presentation to see your cursor move in realtime on their own screen." data-tooltip-alignment="r" data-tooltip-delay="200" data-tooltip-maxwidth="250">','<input id="pointer-checkbox" type="checkbox">','<label for="pointer-checkbox">Show cursor to live viewers</label>',"</div>",'<div class="sl-checkbox flush-left controls-toggle" data-tooltip="Show presentation control arrows and progress bar." data-tooltip-alignment="r" data-tooltip-delay="200" data-tooltip-maxwidth="250">','<input id="controls-checkbox" type="checkbox">','<label for="controls-checkbox">Show presentation controls</label>',"</div>",'<div class="sl-checkbox flush-left notes-toggle" data-tooltip="Show your speaker notes to the audience." data-tooltip-alignment="r" data-tooltip-delay="200" data-tooltip-maxwidth="250">','<input id="notes-checkbox" type="checkbox">','<label for="notes-checkbox">Show speaker notes</label>',"</div>",'<div class="sl-checkbox flush-left upsizing-toggle" data-tooltip="Automatically scale slide content up to fill as much of the browser window as possible." data-tooltip-alignment="r" data-tooltip-delay="200" data-tooltip-maxwidth="250">','<input id="upsizing-checkbox" type="checkbox">','<label for="upsizing-checkbox">Scale up to fill window</label>',"</div>","</div>"].join("")),$('<a class="button xl light-grey edit-button" href="'+this.options.editDeckURL+'" data-tooltip="Edit deck ('+this.options.editDeckShortcut+')"><span class="icon i-pen-alt2"></span></a>').prependTo(this.presentationControlsFooter),$('<button class="button xl light-grey deck-view-button" data-tooltip="'+SL.locale.get("OPEN_DECK_IN")+'"><span class="icon i-tv"></span></a>').prependTo(this.presentationControlsFooter),SL.helpers.Fullscreen.isEnabled()===!1&&this.presentationControls.find(".fullscreen-toggle").hide(),SL.current_deck.get("share_notes")||this.presentationControls.find(".notes-toggle").hide(),this.canShareLiveLink?this.renderLiveShare():this.presentationControls.find(".live-section").remove(),this.canEdit||this.presentationControls.find(".edit-button").remove()},bind:function(){this._super.apply(this,arguments),this.presentationControls.find(".live-view-url").on("mousedown",this.onLiveURLMouseDown.bind(this)),this.presentationControls.find(".pointer-toggle").on("vclick",this.onPointerToggled.bind(this)),this.presentationControls.find(".controls-toggle").on("vclick",this.onControlsToggled.bind(this)),this.presentationControls.find(".notes-toggle").on("vclick",this.onNotesToggled.bind(this)),this.presentationControls.find(".upsizing-toggle").on("vclick",this.onUpsizingToggled.bind(this)),this.presentationControls.find(".sms-link").on("vclick",this.onSMSLinkClicked.bind(this)),this.presentationControls.find(".deck-view-button").on("vclick",this.onDeckViewClicked.bind(this))},syncPresentOptions:function(){this._super.apply(this,arguments),this.presentationControls.find(".pointer-toggle input").prop("checked",SL.current_user.settings.get("present_pointer")),this.presentationControls.find(".controls-toggle input").prop("checked",SL.current_user.settings.get("present_controls")),this.presentationControls.find(".upsizing-toggle input").prop("checked",SL.current_user.settings.get("present_upsizing")),this.presentationControls.find(".notes-toggle input").prop("checked",SL.current_user.settings.get("present_notes")),Reveal.configure({showNotes:SL.current_user.settings.get("present_notes")&&SL.current_deck.get("share_notes"),controls:SL.current_user.settings.get("present_controls"),progress:SL.current_user.settings.get("present_controls"),slideNumber:SL.current_user.settings.get("present_controls")&&SL.current_deck.get("slide_number"),maxScale:SL.current_user.settings.get("present_upsizing")?SL.config.PRESENT_UPSIZING_MAX_SCALE:1}),this.pointer&&this.pointer.setEnabled(SL.current_user.settings.get("present_pointer")&&this.hasStartedPresentation())},renderLiveShare:function(){this.liveShareElement=this.presentationControls.find(".live-share"),SL.current_deck.isVisibilityAll()?this.showLiveShareLink(SL.current_deck.getURL({view:"live"})):this.showLiveShareLinkGenerator()},showLiveShareLinkGenerator:function(){this.presentationControls.find(".live-description").html('Share a link with your audience to have them follow along with the presentation in real-time. Note that all private links you share point to the same live presentation session. <a href="'+this.options.liveViewHelpURL+'" target="_blank">Learn more.</a>'),this.liveShareButton=$('<button class="button l light-grey ladda-button" data-style="zoom-out" data-spinner-color="#222">Share link</button>'),this.liveShareButton.appendTo(this.liveShareElement),this.liveShareButton.on("vclick",function(){"undefined"!=typeof SLConfig&&"string"==typeof SLConfig.deck.user.username&&"string"==typeof SLConfig.deck.slug?SL.popup.open(SL.components.decksharer.DeckSharer,{deck:SL.current_deck,deckView:"live"}):SL.notify(SL.locale.get("GENERIC_ERROR"),"negative")}.bind(this))},showLiveShareLink:function(t){this.liveShareElement.html('<input class="live-view-url input-field" type="text" value="'+t+'" readonly />'),this.liveShareElement.find(".live-view-url").on("mousedown",this.onLiveURLMouseDown.bind(this))},setPresentOption:function(t,e){SL.current_user.settings.set(t,e),this.savePresentOption(t),this.syncPresentOptions();var i={};i[t]=e,this.stream.publish(null,i)},savePresentOption:function(t){this.xhrRequests=this.xhrRequests||{},this.xhrRequests[t]&&this.xhrRequests[t].abort();var e={url:SL.endpoints.UPDATE_USER_SETTINGS,type:"PUT",context:this,data:{user_settings:{}}};e.data.user_settings[t]=SL.current_user.settings.get(t),this.xhrRequests[t]=$.ajax(e).always(function(){this.xhrRequests[t]=null})},startPresentation:function(){this._super.apply(this,arguments),this.pointer&&setTimeout(function(){this.pointer.layout()}.bind(this),500)},showSMSPrompt:function(){this.smsPrompt||(this.smsPrompt=new SL.components.prompts.SMS({anchor:this.presentationControls.find(".sms-link"),title:"Send Remote Control Link",alignment:"r"}),this.smsPrompt.show(),this.smsPrompt.destroyed.add(function(){this.smsPrompt=null}.bind(this)))},onSMSLinkClicked:function(){this.showSMSPrompt()},onLiveURLMouseDown:function(t){$(t.target).focus().select(),t.preventDefault()},onPointerToggled:function(t){t.preventDefault(),this.setPresentOption("present_pointer",!SL.current_user.settings.get("present_pointer"))},onControlsToggled:function(t){t.preventDefault(),this.setPresentOption("present_controls",!Reveal.getConfig().controls)},onNotesToggled:function(t){t.preventDefault(),this.setPresentOption("present_notes",!Reveal.getConfig().showNotes)},onUpsizingToggled:function(t){t.preventDefault(),this.setPresentOption("present_upsizing",Reveal.getConfig().maxScale<=1)},onDeckViewClicked:function(t){new SL.components.prompts.DeckView({anchor:$(t.currentTarget),editorURL:this.getEditorURL(),presentURL:null}).show()},onDocumentKeydown:function(t){return"s"===t.key&&(t.ctrlKey||t.metaKey)?(window.open(this.options.speakerViewURL+window.location.hash),!1):this._super.apply(this,arguments)}}),SL("views.decks").Password=SL.views.Base.extend({OUTRO_DURATION:600,init:function(){this._super(),this.domElement=$(".password-content"),this.formElement=this.domElement.find(".sl-form"),this.inputElement=this.formElement.find(".password-input"),this.submitButton=this.formElement.find(".password-submit"),this.submitLoader=Ladda.create(this.submitButton.get(0)),this.iconElement=$(".password-icon"),this.titleElement=$(".password-title"),this.incorrectPasswordCounter=0,this.incorrectPasswordMessages=["Wrong password, please try again","Still wrong, give it another try","That one was wrong too","Nope"],this.submitButton.on("vclick",this.onSubmitClicked.bind(this)),$(document).on("keydown",this.onKeyDown.bind(this))},submit:function(){if(!this.request){this.submitLoader.start(),this.iconElement.removeClass("wobble");var t={access_token:{password:this.inputElement.val()}},e=this.getDeckTemplateName();"embed"===e&&SL.util.isInIframe()&&(t.template=e),this.request=$.ajax({url:SL.endpoints.ACCESS_TOKENS_PASSWORD_AUTH(SLConfig.access_token_id),type:"PUT",context:this,data:t}).done(function(e){this.domElement.addClass("outro"),this.titleElement.text("All set! Loading deck..."),setTimeout(function(){t.template?(document.open(),document.write(e),document.close()):this.loadDeck()}.bind(this),this.OUTRO_DURATION)}).fail(function(){this.submitLoader.stop(),this.titleElement.text(this.getIncorrectPasswordMessage()),this.iconElement.addClass("wobble"),this.request=null})}},loadDeck:function(){$.ajax({url:window.location.href.replace(/#.*/gi,""),type:"GET",dataType:"html",context:this}).done(function(t){document.open(),document.write(t),document.close()}).fail(function(){window.location.reload()})},getDeckTemplateName:function(){var t=window.location.pathname.split("/");return""===t[t.length-1]&&t.pop(),t=t.pop(),["embed","live","fullscreen"].indexOf(t)!==-1?t:""},getIncorrectPasswordMessage:function(){return this.incorrectPasswordMessages[this.incorrectPasswordCounter++%this.incorrectPasswordMessages.length]},onSubmitClicked:function(t){t.preventDefault(),this.submit()},onKeyDown:function(t){13===t.keyCode&&(t.preventDefault(),this.submit())}}),SL("views.decks").Presenter=SL.views.decks.PresentBase.extend({init:function(){this._super({speakerViewShortcut:SL.util.getKeyboardShortcutName("S",{meta:!0}),speakerViewURL:SL.current_deck.getURL({view:"speaker"})})},setup:function(){return SL.util.isInIframe()||window.opener&&window.opener!==window?(SL.helpers.PageLoader.hide(),$("html").addClass("presentation-started presentation-started-transition-ended"),void $(".global-header").hide()):(window.RevealNotes&&Reveal.registerPlugin(window.RevealNotes),void this._super.apply(this,arguments))},render:function(){this._super.apply(this,arguments),this.presentationControlsContent.append(["<h2>Present View</h2>",'<div class="sl-present-controls-section">',"<h2>Speaker View</h2>","<p>The control panel for your presentation where you can see speaker notes, elapsed time, an upcoming slide preview and more.</p>",'<button class="button l light-grey open-notes" data-tooltip="'+this.options.speakerViewShortcut+'" data-tooltip-alignment="r">Open speaker view <span class="icon i-launch" style="margin-left: 6px;"</span></button>',"</div>",'<div class="sl-present-controls-section sl-form">',"<h2>Options</h2>",'<div class="sl-checkbox flush-left fullscreen-toggle">','<input id="fullscreen-checkbox" type="checkbox">','<label for="fullscreen-checkbox">Fullscreen</label>',"</div>",'<div class="sl-checkbox flush-left controls-toggle" data-tooltip="Show presentation control arrows and progress bar." data-tooltip-alignment="r" data-tooltip-delay="200" data-tooltip-maxwidth="250">','<input id="controls-checkbox" type="checkbox">','<label for="controls-checkbox">Show presentation controls</label>',"</div>",'<div class="sl-checkbox flush-left upsizing-toggle" data-tooltip="Automatically scale slide content up to fill as much of the browser window as possible." data-tooltip-alignment="r" data-tooltip-delay="200" data-tooltip-maxwidth="250">','<input id="upsizing-checkbox" type="checkbox">','<label for="upsizing-checkbox">Scale up to fill window</label>',"</div>","</div>"].join("")),SL.helpers.Fullscreen.isEnabled()===!1&&this.presentationControls.find(".fullscreen-toggle").hide()},bind:function(){this._super.apply(this,arguments),this.presentationControls.find(".controls-toggle").on("vclick",this.onControlsToggled.bind(this)),this.presentationControls.find(".upsizing-toggle").on("vclick",this.onUpsizingToggled.bind(this)),this.presentationControls.find(".open-notes").on("vclick",function(){Reveal.getPlugin("notes").open(SL.config.REVEAL_NOTES_URL)}.bind(this))},syncPresentOptions:function(){this._super.apply(this,arguments),this.presentationControls.find(".controls-toggle input").prop("checked",SL.current_user.settings.get("present_controls")),this.presentationControls.find(".upsizing-toggle input").prop("checked",SL.current_user.settings.get("present_upsizing")),Reveal.configure({controls:SL.current_user.settings.get("present_controls"),progress:SL.current_user.settings.get("present_controls"),slideNumber:SL.current_user.settings.get("present_controls")&&SL.current_deck.get("slide_number"),maxScale:SL.current_user.settings.get("present_upsizing")?SL.config.PRESENT_UPSIZING_MAX_SCALE:1})},setPresentOption:function(t,e){SL.current_user.settings.set(t,e),this.syncPresentOptions()},onControlsToggled:function(t){t.preventDefault(),this.setPresentOption("present_controls",!Reveal.getConfig().controls)},onUpsizingToggled:function(t){t.preventDefault(),this.setPresentOption("present_upsizing",Reveal.getConfig().maxScale<=1)},onDocumentKeydown:function(t){return"s"===t.key&&(t.ctrlKey||t.metaKey)?(Reveal.getPlugin("notes").open(SL.config.REVEAL_NOTES_URL),!1):this._super.apply(this,arguments)}}),SL("views.decks").Print=Class.extend({init:function(){var t=$("#theme-html-output");t&&Reveal.addEventListener("pdf-ready",function(){$(t.remove().prop("outerHTML")).insertAfter(".pdf-page .slide-background"),$(".sl-print-placeholder").remove(),/print\-and\-close/.test(window.location.search)&&this.printAndClose()}.bind(this));var e={showNotes:!!SLConfig.deck.share_notes&&"separate-page",slideNumber:SLConfig.deck.slide_number,autoSlide:0,autoSlideStoppable:!0,rollingLinks:!1,pdfMaxPagesPerSlide:1,presentationMode:SL.deck.Controller.MODE_PRINTING};/HeadlessChrome/.test(navigator.userAgent),SL.util.setupReveal(e),[].slice.call(document.querySelectorAll(".reveal .slides section, .reveal .slide-background")).forEach(function(t){t.classList.add("no-transition"),t.classList.add("present"),t.classList.remove("past"),t.classList.remove("future")}),$(".reveal .slides .sl-block").each(function(){var t=this.style.left,e=this.style.top;t&&e&&(this.style.transform="translate("+t+","+e+")",this.style.zIndex=$(this).find(">.sl-block-content, >.sl-block-style").first().css("z-index"),this.style.left="",this.style.top="")})},printAndClose:function(){$(".sl-print-placeholder").css("display","block");var t=new Promise(function(t){SL.fonts.isReady()===!0?t():SL.fonts.ready.add(t)}),e=new Promise(function(t){"complete"===document.readyState?t():window.addEventListener("load",t)});Promise.all([t,e]).then(function(){window.print(),window.close()})}}),SL("views.decks").Review=SL.views.Base.extend({init:function(){this._super(),$("html").toggleClass("small-mode",window.innerWidth<850),SL.util.setupReveal({help:!1,hash:!0,shuffle:!1,openLinksInTabs:!0,margin:.15}),SL.helpers.PageLoader.show(),this.setupCollaboration().then(function(){SL.fonts.isReady()?SL.helpers.PageLoader.hide():SL.fonts.ready.add(SL.helpers.PageLoader.hide)}),SL.session.enforce()},setupCollaboration:function(){this.collaboration=new SL.components.collab.Collaboration({container:document.body,fixed:!$("html").hasClass("small-mode"),autofocusComment:!1});var t=new Promise(function(t){this.collaboration.loaded.add(function(){t()}.bind(this))}.bind(this));return this.collaboration.load(),t}}),SL("views.decks").Show=SL.views.Base.extend({init:function(){this._super(),SL.util.setupReveal({hash:!0,embedded:!0,pause:!1,preventMediaDownloads:!0,openLinksInTabs:!0,trackEvents:!0});var t=SL.util.setupFloatingAd(),e=window.innerWidth<600;this.setupDisqus(),t||e||this.setupPills(),$("header .deck-promotion").length&&$("header").addClass("extra-wide"),this.bind(),this.layout()},bind:function(){this.editButton=$(".deck-options .edit-button"),this.editButtonOriginalLink=this.editButton.attr("href"),$(".deck-options .fork-button").on("vclick",this.onForkClicked.bind(this)),$(".deck-options .share-button").on("vclick",this.onShareClicked.bind(this)),$(".deck-options .comment-button").on("vclick",this.onCommentsClicked.bind(this)),$(".deck-options .deck-view-button").on("vclick",this.onDeckViewClicked.bind(this)),Modernizr.fullscreen===!0&&$(".deck-options .fullscreen-button").on("vclick",this.onFullScreenClicked.bind(this)),this.visibilityButton=$(".deck-options .visibility-button"),this.visibilityButton.on("vclick",this.onVisibilityClicked.bind(this)),$(document).on("webkitfullscreenchange mozfullscreenchange MSFullscreenChange fullscreenchange",Reveal.layout),this.onWindowScroll=$.debounce(this.onWindowScroll,200),$(window).on("resize",this.layout.bind(this)),$(window).on("scroll",this.onWindowScroll.bind(this)),$(window).on("orientationchange",this.onOrientationChange.bind(this)),Reveal.addEventListener("slidechanged",this.onSlideChanged.bind(this)),Reveal.addEventListener("fragmentshown",this.hideSummary),Reveal.addEventListener("fragmenthidden",this.hideSummary)},setupPills:function(){this.hideSummary=this.hideSummary.bind(this),this.hideInstructions=this.hideInstructions.bind(this),this.summaryPill=$(".summary-pill"),this.instructionsPill=$(".instructions-pill"),this.summaryPill.on("click",this.hideSummary),this.instructionsPill.on("click",this.hideInstructions),window.innerHeight-$(".deck-info").offset().top<100&&(this.showSummaryTimeout=setTimeout(this.showSummary.bind(this),1e3),this.hideSummaryTimeout=setTimeout(this.hideSummary.bind(this),6e3)),this.showNavigationInstructions()},setupDisqus:function(){$("#disqus_thread").length?setTimeout(function(){var t=window.disqus_shortname="slidesapp";window.disqus_identifier=SLConfig.deck.id;!function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src="//"+t+".disqus.com/embed.js",(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(e)}()},200):$(".options .comment-button").hide()},showSummary:function(){this.summaryPill&&this.summaryPill.addClass("visible")},hideSummary:function(){clearTimeout(this.showSummaryTimeout),this.summaryPill&&(this.summaryPill.removeClass("visible"),this.summaryPill.on("transitionend",this.summaryPill.remove),this.summaryPill=null)},canShowInstructions:function(){return!SL.util.user.isLoggedIn()&&!SL.util.device.IS_PHONE&&!SL.util.device.IS_TABLET&&Reveal.getTotalSlides()>1&&Modernizr.localstorage},showNavigationInstructions:function(){this.showInstructions("slides-has-seen-deck-navigation-instructions",6e3,{title:"Navigation instructions",description:"Press the space key or click the arrows to the right"})},showVerticalInstructions:function(){this.showInstructions("slides-has-seen-deck-vertical-instructions",1e3,{title:"There's a vertical slide below",description:"Use the controls to the right or the keyboard arrows",icon:"down-arrow"})},showInstructions:function(t,e,i){clearTimeout(this.showInstructionsTimeout),this.instructionsPill&&this.canShowInstructions()&&!localStorage.getItem(t)&&(localStorage.setItem(t,"yes"),this.showInstructionsTimeout=setTimeout(function(){this.instructionsPill.attr("data-icon",i.icon),this.instructionsPill.find(".pill-title").text(i.title),this.instructionsPill.find(".pill-description").text(i.description),this.instructionsPill.addClass("visible"),this.layout()}.bind(this),e))},hideInstructions:function(){clearTimeout(this.showInstructionsTimeout),this.instructionsPill&&this.instructionsPill.removeClass("visible")},layout:function(){this.summaryPill&&this.summaryPill.css("left",(window.innerWidth-this.summaryPill.width())/2),this.instructionsPill&&this.instructionsPill.css("left",(window.innerWidth-this.instructionsPill.width())/2);var t=$(".reveal .playback"),e=$(".deck-kudos"),i={opacity:1};e.length&&t.length&&(i.marginLeft=t.offset().left+t.outerWidth()-10),e.css(i)},onShareClicked:function(){return"undefined"!=typeof SLConfig&&"string"==typeof SLConfig.deck.user.username&&"string"==typeof SLConfig.deck.slug?SL.popup.open(SL.components.decksharer.DeckSharer,{deck:SL.current_deck}):SL.notify(SL.locale.get("GENERIC_ERROR"),"negative"),SL.analytics.trackPresenting("Share clicked"),!1},onCommentsClicked:function(){SL.analytics.trackPresenting("Comments clicked")},onDeckViewClicked:function(t){new SL.components.prompts.DeckView({anchor:$(t.currentTarget),deckURL:null}).show()},onFullScreenClicked:function(t){var e=$(".reveal-viewport").get(0);return e?(SL.helpers.Fullscreen.enter(e),t.preventDefault(),!1):void SL.analytics.trackPresenting("Fullscreen clicked")},onForkClicked:function(){return SL.analytics.trackPresenting("Fork clicked"),$.ajax({type:"POST",url:SL.endpoints.FORK_DECK(SLConfig.deck.id),context:this}).done(function(){window.location=SL.current_user.getProfileURL()}).fail(function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative")}),!1},onVisibilityClicked:function(t){t.preventDefault();var e=new SL.components.prompts.DeckVisibility(SL.current_deck,{anchor:$(t.currentTarget)});e.show(),SL.analytics.trackPresenting("Visibility menu opened")},onSlideChanged:function(t){this.hideSummary(),this.hideInstructions();var e="#";t.indexh&&(e+="/"+t.indexh,t.indexv&&(e+="/"+t.indexv)),this.editButton.attr("href",this.editButtonOriginalLink+e),t.indexh>0&&0===t.indexv&&Reveal.availableRoutes().down&&this.showVerticalInstructions()},onWindowScroll:function(){$(window).scrollTop()>10&&(this.hideSummary(),this.hideInstructions())},onOrientationChange:function(){window.scrollTo(0,0)}}),SL("views.decks").Speaker=SL.views.Base.extend({init:function(){this._super();var t=window.innerWidth<700||SL.util.device.isiPhone();$("html").toggleClass("speaker-mobile",t),this.controlsElement=$(".speaker-controls"),this.timerElement=$(".speaker-timer"),this.timerValue=$(".speaker-timer .timer-value"),this.timerHoursValue=$(".speaker-timer .timer-value .hours"),this.timerMinutesValue=$(".speaker-timer .timer-value .minutes"),this.timerSecondsValue=$(".speaker-timer .timer-value .seconds"),this.timerClockValue=$(".speaker-timer .clock-value"),this.timerSettingsButton=$(".speaker-timer .timer-settings"),this.progressElement=$(".speaker-progress"),this.progressStatus=$(".speaker-progress .status"),this.progressSlideNumber=$(".speaker-progress .slide-number"),this.progressBar=$(".speaker-progress-bar .speaker-inner-bar"),this.countdownBar=$(".speaker-countdown-bar .speaker-inner-bar"),this.notesElement=$(".speaker-notes"),this.notesValue=$(".speaker-notes .value"),this.subscribersElement=$(".subscribers"),this.subscribersValue=$(".subscribers .subscribers-value"),this.currentElement=$(".current-slide"),this.speakerLayout=$(".speaker-layout-button"),this.speakerLayout.on("vclick",this.onLayoutClicked.bind(this)),this.speakerDarkMode=$(".speaker-dark-mode-button"),this.speakerDarkMode.on("vclick",this.toggleDarkMode.bind(this)),$(".reveal [data-autoplay]").removeAttr("data-autoplay"),$(".reveal [data-background-video]").attr("data-background-video-muted",!0),this.countdownInMilliseconds=0,this.isMobileSpeakerView()||(this.setLayout(SL.current_user.settings.get("speaker_layout")),this.upcomingElement=$(".upcoming-slide"),this.upcomingFrame=$(".upcoming-slide iframe"),this.upcomingJumpTo=$(".upcoming-slide-jump-to"),this.upcomingJumpTo.on("vclick",this.onJumpToUpcomingSlide.bind(this))),this.setDefaultTheme(),this.upcomingFrame&&this.upcomingFrame.length?this.loadUpcomingFrame().then(this.setup.bind(this)):this.setup(),SL.helpers.PageLoader.show()},setup:function(){this.syncTimerSettings(),SL.util.setupReveal({touch:!0,history:!1,shuffle:!1,progress:!1,autoPlayMedia:!1,autoSlide:0,openLinksInTabs:!0,trackEvents:!0,showNotes:!1,controlsTutorial:!1}),Reveal.isReady()?this.afterRevealReady():Reveal.addEventListener("ready",this.afterRevealReady.bind(this))},afterRevealReady:function(){this.currentReveal=window.Reveal,this.currentReveal.addEventListener("slidechanged",this.onCurrentSlideChanged.bind(this)),this.currentReveal.addEventListener("fragmentshown",this.onCurrentFragmentChanged.bind(this)),this.currentReveal.addEventListener("fragmenthidden",this.onCurrentFragmentChanged.bind(this)),this.currentReveal.addEventListener("paused",this.onCurrentPaused.bind(this)),this.currentReveal.addEventListener("resumed",this.onCurrentResumed.bind(this)),this.setupTimer(),this.setupTouch();var t={reveal:this.currentReveal,publisher:!0,showErrors:!0};SL.util.user.isPseudoLoggedIn()&&(t.deckReloadEndpoint=window.location.pathname+".json"),this.stream=new SL.helpers.StreamLive(t),this.stream.ready.add(this.onStreamReady.bind(this)),this.stream.deckChanged.add(this.onStreamDeckChanged.bind(this)),this.stream.stateChanged.add(this.onStreamStateChanged.bind(this)),this.stream.subscribersChanged.add(this.onStreamSubscribersChanged.bind(this)),this.stream.timerStart.add(this.startTimer.bind(this)),this.stream.timerPause.add(this.pauseTimer.bind(this)),this.stream.timerStop.add(this.stopTimer.bind(this)),this.stream.timerSync.add(this.onStreamTimerSync.bind(this)),this.stream.timerRequestSync.add(this.onStreamTimerRequestSync.bind(this)),this.stream.connect(),this.isMobileSpeakerView()||this.setupPointer(),this.layout(),window.addEventListener("resize",this.layout.bind(this))},loadUpcomingFrame:function(){return this.upcomingFrame&&this.upcomingFrame.length?new Promise(function(t){var e=function(){this.upcomingFrame.off("load",e),this.bindUpcomingReveal().then(this.setupUpcomingReveal.bind(this)).then(t)}.bind(this),i=this.upcomingFrame.attr("data-src");i+=/\?/g.test(i)?"&":"?",i+="t="+Date.now(),this.upcomingFrame.on("load",e),this.upcomingFrame.attr("src",i)}.bind(this)):Promise.resolve()},bindUpcomingReveal:function(){if(this.upcomingFrame&&this.upcomingFrame.length){try{this.upcomingReveal=this.upcomingFrame.get(0).contentWindow.Reveal}catch(t){console.warn("Unable to find upcoming reveal instance. Upcoming preview will be disabled.")}return this.upcomingReveal?new Promise(function(t){this.upcomingReveal.isReady()?t():this.upcomingReveal.addEventListener("ready",t)}.bind(this)):(this.upcomingElement.addClass("not-available"),this.upcomingElement=null,this.upcomingReveal=null,this.upcomingFrame=null,Promise.resolve())}return Promise.resolve()},setupUpcomingReveal:function(){this.upcomingReveal&&(this.upcomingReveal.configure({history:!1,controls:!1,progress:!1,overview:!1,autoPlayMedia:!1,autoSlide:0,transition:"none",backgroundTransition:"none"}),this.upcomingReveal.addEventListener("slidechanged",this.onUpcomingSlideChanged.bind(this)),this.upcomingReveal.addEventListener("fragmentshown",this.onUpcomingFragmentChanged.bind(this)),this.upcomingReveal.addEventListener("fragmenthidden",this.onUpcomingFragmentChanged.bind(this)),this.upcomingFrame.get(0).contentWindow.document.body.className+=" no-transition",this.syncJumpButton())},setupTouch:function(){if(this.isMobileSpeakerView()){var t=!(!SL.util.device.HAS_TOUCH&&!window.navigator.pointerEnabled);t&&this.progressStatus.text("Tap or Swipe to change slide"),this.progressElement.appendTo(this.controlsElement);var e=document.body,i=new Hammer(e);i.get("swipe").set({direction:Hammer.DIRECTION_ALL}),i.get("press").set({threshold:1e3}),$(e).on("touchstart",function(t){1===t.originalEvent.touches.length&&1===$(t.originalEvent.target).closest(".notes-overflowing").length?(i.stop(),$(e).one("touchend",function(e){if(e.originalEvent.changedTouches&&1===e.originalEvent.changedTouches.length){var i={x:t.originalEvent.touches[0].pageX,y:t.originalEvent.touches[0].pageY},n={x:e.originalEvent.changedTouches[0].pageX,y:e.originalEvent.changedTouches[0].pageY};"number"==typeof i.x&&"number"==typeof i.x&&"number"==typeof n.x&&"number"==typeof n.x&&SL.util.trig.distanceBetween({x:i.x,y:i.y},{x:n.x,y:n.y})<10&&(this.currentReveal.next(),this.showStatusMessage("Next slide"))}}.bind(this))):t.preventDefault()}.bind(this)),i.on("swipe",function(t){switch(t.direction){case Hammer.DIRECTION_LEFT:this.currentReveal.right(),this.showStatusMessage("Next slide");break;case Hammer.DIRECTION_RIGHT:this.currentReveal.left(),this.showStatusMessage("Previous slide");break;case Hammer.DIRECTION_UP:this.currentReveal.down(),this.showStatusMessage("Next vertical slide");break;case Hammer.DIRECTION_DOWN:this.currentReveal.up(),this.showStatusMessage("Previous vertical slide")}}.bind(this)),i.on("tap",function(t){$(t.target).closest(".timer-option, .sl-notification, .reveal .controls, .sl-prompt").length>0?t.preventDefault():(this.currentReveal.next(),this.showStatusMessage("Next slide"))}.bind(this)),i.on("press",function(){this.currentReveal.isPaused()&&(this.currentReveal.togglePause(!1),this.showStatusMessage("Resumed"))}.bind(this))}},setupPointer:function(){this.pointer=new SL.components.StreamPointer({publisher:!0,stream:this.stream,hideDefault:!0,container:this.currentElement.get(0)}),this.syncPointer()},setupTimer:function(){this.controlsElement.find(".timer-rewind-button").on("vclick",function(t){t.preventDefault(),this.currentReveal.slide(0,0,0),this.stream.broadcast({type:"timer:stop"}),this.stopTimer(),this.showStatusMessage("Presentation reset to first slide")}.bind(this)),this.controlsElement.find(".timer-start-button, .timer-resume-button").on("vclick",function(t){t.preventDefault(),this.stream.broadcast({type:"timer:start"}),this.startTimer(),this.showStatusMessage("Timer started")}.bind(this)),this.controlsElement.find(".timer-pause-button").on("vclick",function(t){t.preventDefault(),this.stream.broadcast({type:"timer:pause"}),this.pauseTimer(),this.showStatusMessage("Timer paused")}.bind(this)),this.controlsElement.find(".timer-stop-button").on("vclick",function(t){t.preventDefault(),this.stream.broadcast({type:"timer:stop"}),this.stopTimer(),this.showStatusMessage("Timer reset")}.bind(this)),this.timerSettingsButton.on("vclick",function(){var t=new SL.components.prompts.DeckTiming({anchor:this.timerSettingsButton,alignment:"t"});t.show(),t.confirmed.add(function(){this.syncTimerSettings(),this.syncTimer(),this.syncStreamTimers()}.bind(this))}.bind(this)),setInterval(this.syncTimer.bind(this),1e3)},stopTimer:function(){delete this.startTime,delete this.pauseTime,this.syncTimer()},pauseTimer:function(){this.pauseTime=Date.now(),this.syncTimer()},startTimer:function(){this.startTime||(this.startTime=Date.now()+1),"number"==typeof this.pauseTime&&(this.startTime+=Date.now()-this.pauseTime,delete this.pauseTime),this.syncTimer()},layout:function(){var t=window.innerHeight-this.notesValue.offset().top-10;this.isMobileSpeakerView()?this.progressElement&&(t-=this.progressElement.outerHeight()):this.subscribersElement.hasClass("visible")&&(t-=this.subscribersElement.outerHeight()),
this.notesValue.height(t),this.syncNotesOverflow()},setLayout:function(t,e){$("html").attr("data-speaker-layout",t),this.currentReveal&&this.currentReveal.layout(),this.upcomingReveal&&this.upcomingReveal.layout(),this.layout(),e&&(SL.current_user.settings.set("speaker_layout",t),SL.current_user.settings.save(["speaker_layout"]))},getLayout:function(){return SL.current_user.settings.get("speaker_layout")||SL.views.decks.Speaker.LAYOUT_DEFAULT},setDefaultTheme:function(){var t=SL.current_user.settings.get("speaker_theme");"string"!=typeof t&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches&&(t="dark"),("dark"===t||this.isMobileSpeakerView())&&this.toggleDarkMode(!0)},toggleDarkMode:function(t){"boolean"!=typeof t&&(t="dark"!==document.documentElement.getAttribute("data-speaker-theme")),t===!0?(document.documentElement.setAttribute("data-speaker-theme","dark"),SL.current_user.settings.set("speaker_theme","dark")):(document.documentElement.removeAttribute("data-speaker-theme"),SL.current_user.settings.set("speaker_theme","light")),SL.current_user.settings.save(["speaker_theme"])},sync:function(){setTimeout(function(){this.syncUpcomingSlide(),this.syncNotes(),this.syncNotesOverflow(),this.syncTimer()}.bind(this),1)},syncTimer:function(){var t=moment();this.timerClockValue.html(t.format("hh:mm")+' <span class="dim">'+t.format("A")+"<span>");var e={hh:"00",mm:"00",ss:"00"};this.isCountdownSpecified()?e=this.getFormattedCountdown(this.getRemainingCountdownInSeconds()):this.isTimerStarted()&&(t.hour(0).minute(0).second((this.getUnixTime()-this.startTime)/1e3),e.hh=t.format("HH"),e.mm=t.format("mm"),e.ss=t.format("ss")),this.isTimerPaused()?this.timerElement.attr("data-timer-state","paused"):this.isTimerStarted()?this.timerElement.attr("data-timer-state","started"):this.timerElement.attr("data-timer-state","idle"),this.timerHoursValue.text(e.hh).toggleClass("isset","00"!==e.hh),this.timerMinutesValue.text(e.mm).toggleClass("isset","00"!==e.mm),this.timerSecondsValue.text(e.ss).toggleClass("isset","00"!==e.ss),this.timerValue.toggleClass("overtime",e.overtime===!0),this.syncProgress()},syncStreamTimers:function(){this.isTimerStarted()&&this.stream.broadcast({type:"timer:sync",startTime:this.startTime,pauseTime:this.pauseTime,timeLimit:SL.current_deck.get("time_limit")})},syncUpcomingSlide:function(){if(this.upcomingReveal){var t=this.currentReveal.getIndices();this.upcomingReveal.slide(t.h,t.v,t.f),this.upcomingReveal.next();var e=this.upcomingReveal.getIndices();this.upcomingElement.toggleClass("is-last-slide",t.h===e.h&&t.v===e.v&&t.f===e.f)}},syncJumpButton:function(){if(this.currentReveal&&this.upcomingReveal){var t=this.currentReveal.getIndices(),e=this.upcomingReveal.getIndices();this.upcomingJumpTo.toggleClass("hidden",t.h===e.h&&t.v===e.v&&t.f===e.f)}},syncNotes:function(){var t=$(this.currentReveal.getCurrentSlide()).attr("data-notes")||"";if(t){this.notesElement.show();var e=this.notesValue.text();e!==t&&this.notesValue.text(t).scrollTop(0)}else this.notesValue.scrollTop(0),this.notesElement.hide()},syncNotesOverflow:function(){this.notesValue.toggleClass("notes-overflowing",this.notesValue.prop("scrollHeight")>this.notesValue.height())},syncProgress:function(){if(this._firstProgressSync||(this._firstProgressSync=!0,SL.util.skipCSSTransitions(this.progressElement)),this.isCountdownSpecified()){var t=1-this.getCountdownProgress();this.countdownBar.show().css({"-webkit-transform":"scale("+t+", 1)","-ms-transform":"scale("+t+", 1)",transform:"scale("+t+", 1)"})}else this.countdownBar.hide();var e=this.currentReveal.getProgress();this.progressBar.css({"-webkit-transform":"scale("+e+", 1)","-ms-transform":"scale("+e+", 1)",transform:"scale("+e+", 1)"});var i=Reveal.getTotalSlides(),n=this.currentReveal.getIndices(),s=n.h+n.v;s+=$(".reveal .slides>section.present").prevAll("section").find(">section:gt(0)").length,s+=1,this.progressSlideNumber.html(s+"/"+i)},syncPointer:function(){this.pointer&&this.pointer.setEnabled(SL.current_user.settings.get("present_pointer"))},showStatusMessage:function(t){if(this.isMobileSpeakerView()){clearTimeout(this.statusMessageTimeout);var e=this.currentReveal&&this.currentReveal.isPaused();e&&(t="Paused (tap+hold to resume)"),this.progressStatus&&(this.progressStatus.text(t).removeClass("hidden"),e||(this.statusMessageTimeout=setTimeout(function(){this.progressStatus.addClass("hidden")}.bind(this),1e3)))}},syncTimerSettings:function(){var t=SL.current_deck.get("time_limit");"number"==typeof t&&(this.countdownInMilliseconds=60*t*1e3),"number"==typeof t&&t>0?this.timerSettingsButton.text("Limit: "+t+"min"):this.isMobileSpeakerView()?this.timerSettingsButton.text("Time limit"):this.timerSettingsButton.text("Set time limit"),this.controlsElement.toggleClass("has-time-limit",this.isCountdownSpecified())},getFormattedCountdown:function(t){var e=t<0;t=Math.abs(t);var i=Math.floor(t/60),n=Math.floor(t/60/60);return t%=60,i%=60,t<10&&(t="0"+t),i<10&&(i="0"+i),n<10&&(n="0"+n),{hh:n,mm:i,ss:t,overtime:e}},getUnixTime:function(){return this.isTimerPaused()?this.pauseTime:Date.now()},getRemainingCountdownInSeconds:function(){return this.isTimerStarted()?moment(this.startTime+this.countdownInMilliseconds).diff(this.getUnixTime(),"seconds"):this.countdownInMilliseconds/1e3},getCountdownProgress:function(){if(this.isCountdownSpecified())return Math.min(1-this.getRemainingCountdownInSeconds()/(this.countdownInMilliseconds/1e3),1)},isMobileSpeakerView:function(){return $("html").hasClass("speaker-mobile")},isTimerStarted:function(){return this.startTime&&this.startTime>0},isTimerPaused:function(){return this.pauseTime&&this.pauseTime>0},isCountdownSpecified:function(){return this.countdownInMilliseconds>0},onUpcomingFrameLoaded:function(){this.setup()},onStreamReady:function(){SL.helpers.PageLoader.hide(),this.sync(),this.stream.broadcast({type:"timer:request-sync"})},onStreamDeckChanged:function(){this.syncNotes(),this.loadUpcomingFrame().then(this.syncUpcomingSlide.bind(this))},onStreamStateChanged:function(t){t&&"boolean"==typeof t.present_pointer&&(SL.current_user.settings.set("present_pointer",t.present_pointer),this.syncPointer())},onStreamSubscribersChanged:function(t){"number"==typeof this.subscriberCount&&(this.subscribersValue.removeClass("flash green flash-red"),t>this.subscriberCount?setTimeout(function(){this.subscribersValue.addClass("flash-green")}.bind(this),1):t<this.subscriberCount&&setTimeout(function(){this.subscribersValue.addClass("flash-red")}.bind(this),1)),this.subscriberCount=t,this.subscriberCount>0?(this.subscribersValue.html('<span class="icon i-eye"></span>'+t),this.subscribersElement.addClass("visible")):this.subscribersElement.removeClass("visible"),this.layout()},onStreamTimerSync:function(t){t&&("number"!=typeof t.timeLimit||isNaN(t.timeLimit)||(SL.current_deck.set("time_limit",t.timeLimit),this.syncTimerSettings()),"number"==typeof t.startTime&&t.startTime>0&&(!this.isTimerStarted()||t.startTime>this.startTime)&&(this.startTime=t.startTime,"number"==typeof t.pauseTime&&t.pauseTime>0&&(this.pauseTime=t.pauseTime),this.syncTimer()))},onStreamTimerRequestSync:function(){this.syncStreamTimers()},onCurrentSlideChanged:function(){this.isTimerStarted()&&!this.isTimerPaused()||this.startTimer(),this.sync()},onCurrentFragmentChanged:function(){this.isTimerStarted()&&!this.isTimerPaused()||this.startTimer(),this.sync()},onCurrentPaused:function(){this.pausedInstructions||(this.pausedInstructions=$('<h3 class="message-overlay">Paused. Press the "B" key to resume.</h3>'),this.pausedInstructions.appendTo(this.currentElement),this.pausedInstructions.addClass("visible"))},onCurrentResumed:function(){this.pausedInstructions&&(this.pausedInstructions.remove(),this.pausedInstructions=null)},onUpcomingSlideChanged:function(){this.syncJumpButton()},onUpcomingFragmentChanged:function(){this.syncJumpButton()},onJumpToUpcomingSlide:function(){var t=this.upcomingReveal.getIndices();this.currentReveal.slide(t.h,t.v,t.f),this.syncUpcomingSlide()},onLayoutClicked:function(t){t.preventDefault();var e=this.getLayout();SL.prompt({anchor:this.speakerLayout,type:"select",title:"Speaker layout",className:"sl-speaker-layout-prompt",data:[{html:'<div class="speaker-layout-icon" data-speaker-layout="'+SL.views.decks.Speaker.LAYOUT_DEFAULT+'"></div><h3>Default</h3>',selected:e===SL.views.decks.Speaker.LAYOUT_DEFAULT,callback:this.setLayout.bind(this,SL.views.decks.Speaker.LAYOUT_DEFAULT,!0)},{html:'<div class="speaker-layout-icon" data-speaker-layout="'+SL.views.decks.Speaker.LAYOUT_WIDE+'"></div><h3>Wide</h3>',selected:e===SL.views.decks.Speaker.LAYOUT_WIDE,callback:this.setLayout.bind(this,SL.views.decks.Speaker.LAYOUT_WIDE,!0)},{html:'<div class="speaker-layout-icon" data-speaker-layout="'+SL.views.decks.Speaker.LAYOUT_TALL+'"></div><h3>Tall</h3>',selected:e===SL.views.decks.Speaker.LAYOUT_TALL,callback:this.setLayout.bind(this,SL.views.decks.Speaker.LAYOUT_TALL,!0)},{html:'<div class="speaker-layout-icon" data-speaker-layout="'+SL.views.decks.Speaker.LAYOUT_NOTES_ONLY+'"></div><h3>Notes only</h3>',selected:e===SL.views.decks.Speaker.LAYOUT_NOTES_ONLY,callback:this.setLayout.bind(this,SL.views.decks.Speaker.LAYOUT_NOTES_ONLY,!0)}]})}}),SL.views.decks.Speaker.LAYOUT_DEFAULT="default",SL.views.decks.Speaker.LAYOUT_WIDE="wide",SL.views.decks.Speaker.LAYOUT_TALL="tall",SL.views.decks.Speaker.LAYOUT_NOTES_ONLY="notes-only",SL("views.devise").All=SL.views.Base.extend({init:function(){this._super(),this.setupForm(),this.setupToggles(),this.setupRegistration()},setupForm:function(){this.formElement=$("form"),this.formElement.length&&(this.formElement.find(".unit[data-validate]").each(function(t,e){new SL.components.FormUnit(e)}),this.formSubmit=this.formElement.find("button[type=submit]"),this.formSubmit.length&&this.formElement.on("submit",function(t){t.isDefaultPrevented()||($(".g-recaptcha").length&&"undefined"!=typeof window.grecaptcha?(t.preventDefault(),grecaptcha.execute()):Ladda.create(this.formSubmit.get(0)).start())}.bind(this))),$(".field-info[data-tooltip]").on("vclick",function(){SL.prompt({title:$(this).attr("data-title"),bodyText:$(this).attr("data-tooltip"),confirmButton:!0,confirmLabel:"Close"})})},onGoogleRecaptchaValidated:function(t){this.formElement.append('<input id="g-recaptcha-response" name="g-recaptcha-response" type="hidden" value="'+t+'">'),Ladda.create(this.formSubmit.get(0)).start(),this.formElement.get(0).submit()},setupToggles:function(){$(".auth-toggle").on("vclick",function(t){t.preventDefault();var e=$(this).siblings(".auth-toggle-content");e.length&&(e.toggleClass("hidden"),$(this).toggleClass("expanded",!e.hasClass("hidden")),e.hasClass("hidden")===!1&&e.find('input[type="text"], input[type="email"]').first().focus())})},setupRegistration:function(){var t=$(".registration-toggle");t.length&&($(".registration-toggle").on("vclick",function(t){var e=$(t.currentTarget).parent();e.addClass("selected").siblings().removeClass("selected"),this.syncRegistration(),t.preventDefault()}.bind(this)),$("#submit-button").on("click",function(t){var e=$(".registration-option.selected[data-omniauth-url]").attr("data-omniauth-url");if(e){var i=$("#user_email_subscriber").is(":checked");window.location=e+"?email_subscriber="+i,t.preventDefault()}}));var e=$("#terms_agreement");e.length&&(e.on("change",function(){this.syncRegistration()}.bind(this)),this.formElement.on("keypress",function(t){13===t.keyCode&&"function"==typeof this.formElement.get(0).checkValidity&&this.formElement.get(0).checkValidity()&&(e.is(":checked")||SL.notify("Please agree to the Terms of Service and Privacy policy before proceeding."))}.bind(this)))},syncRegistration:function(){var t=$("#submit-button");$("#terms_agreement").is(":checked")?t.removeAttr("disabled").removeAttr("data-tooltip").removeClass("disabled"):t.attr("disabled","disabled").addClass("disabled");var e=$(".registration-option.selected");$("#submit-button").text(e.attr("data-submit-label")).attr("data-option-id",e.attr("data-option-id"))}}),SL("views.devise").Edit=SL.views.devise.All.extend({init:function(){this._super(),$("[data-toggle-content]").on("click",this.onContentToggled.bind(this)),$(".delete-profile-photo").on("click",this.onDeleteProfilePhotoClicked.bind(this)),$("#user_email").on("change keyup",this.onEmailChanged.bind(this)),$("#user_password").on("change keyup",this.onNewPasswordChanged.bind(this)),this.undoAutoFill()},undoAutoFill:function(){if(navigator.userAgent.toLowerCase().indexOf("chrome")>=0)var t=window.setInterval(function(){var e=$("input:-webkit-autofill");e.length>0&&(window.clearInterval(t),e.each(function(){var t=$(this).clone(!0,!0);t.is("[type=password]")&&t.val(""),$(this).after(t).remove();var e=t.parent(".unit");e.length&&new SL.components.FormUnit(e)}))},20)},updatePasswordVerification:function(){var t=$("#user_email").parents(".unit"),e=$("#user_password").parents(".unit"),i=$("#user_current_password").parents(".unit"),n=t.data("controller"),s=e.data("controller");n&&s&&n.isUnchanged()&&s.isUnchanged()?(i.removeAttr("data-required"),i.addClass("hidden")):(i.attr("data-required","true"),i.removeClass("hidden"))},onContentToggled:function(t){t.preventDefault(),$(t.currentTarget).toggleClass("active"),$("."+$(t.currentTarget).attr("data-toggle-content")).toggleClass("visible")},onDeleteProfilePhotoClicked:function(t){t.preventDefault(),$.ajax({url:SL.endpoints.UPDATE_USER,type:"PUT",context:this,data:{user:{profile_photo:""}}}).done(function(){$(".photo-editor").attr("data-photo-type","gravatar")}).fail(function(){SL.notify("An error occured while saving","negative")})},onEmailChanged:function(){this.updatePasswordVerification()},onNewPasswordChanged:function(){this.updatePasswordVerification()}}),SL("views.funnels").All=SL.views.Base.extend({init:function(){this._super(),this.setup(),this.bind(),$(".feature").first().find("video[data-poster]").each(function(){this.setAttribute("poster",this.getAttribute("data-poster"))});var t=$(".features[data-pricing-link]").attr("data-pricing-link");t&&$('a[href="/pricing"]').attr("href",t),this.syncMedia()},setup:function(){(SL.util.device.IS_PHONE||SL.util.device.IS_TABLET)&&$(".feature video").each(function(){$(this).prop("controls",!0),SL.util.device.IS_TABLET&&$(this).prop("autoplay",!0)}),$(".feature").each(function(t,e){e=$(e),video=e.find("video"),video.length&&(SL.util.device.IS_PHONE||SL.util.device.IS_TABLET?(e.addClass("loaded"),this.loadFeatureAnimation(e)):video.on("loadeddata",function(){e.addClass("loaded"),e.hasClass("playing")&&this.startFeatureAnimation(e)}.bind(this)))}.bind(this))},bind:function(){this.syncMedia=$.throttle(this.syncMedia.bind(this),300),$(window).on("resize",this.syncMedia),$(window).on("scroll",this.syncMedia)},syncMedia:function(){var t=$(window).scrollTop();if(!SL.util.device.IS_PHONE&&!SL.util.device.IS_TABLET){var e=window.innerHeight;$(".feature").each(function(t,i){i=$(i);var n=i.get(0).getBoundingClientRect(),s=i.hasClass("playing"),o=i.hasClass("loaded"),a=0===t?-20:100;!o&&n.bottom>-200&&n.top<e+a&&this.loadFeatureAnimation(i),n.top+n.height/2>0&&n.top+n.height/2<e?s||this.startFeatureAnimation(i):s&&this.stopFeatureAnimation(i)}.bind(this))}!this.postersLoaded&&t>20&&(this.postersLoaded=!0,$(".feature video[data-poster]").each(function(){this.setAttribute("poster",this.getAttribute("data-poster")),this.removeAttribute("data-poster")}))},loadFeatureAnimation:function(t){var e=t.find("video");if(e.length){var i=e.find("span[data-src]");if(i.length){var n="";e.find("span[data-src]").each(function(t,e){e=$(e),n+='<source src="'+e.attr("data-src")+'" type="'+e.attr("data-type")+'">'}),n&&e.html(n)}}},startFeatureAnimation:function(t){t.addClass("playing");var e=t.find("video").get(0);e&&t.hasClass("loaded")&&e.play()},stopFeatureAnimation:function(t){t.removeClass("playing");var e=t.find("video").get(0);e&&t.hasClass("loaded")&&e.pause()}}),SL("views.home").Explore=SL.views.Base.extend({init:function(){this._super(),new SL.components.Search({url:SL.endpoints.SEARCH})}}),SL("views.home").Features=SL.views.Base.extend({init:function(){$("[data-preview-media]").each(function(t,e){var i=$(e).closest("h4").clone();i.find("*").remove();var n=i.text().trim();n&&$(e).attr("data-preview-title",n)}),this._super()}}),SL("views.home").Index=SL.views.Base.extend({MARQUEE_MIN_HEIGHT:600,init:function(){this._super(),this.learnMoreButton=$(".marquee .description-cta-secondary"),this.scrollPromotion=$(".marquee .scroll-promotion"),this.scrollPromotionArrow=$(".marquee .scroll-promotion-arrow"),this.bind(),this.runMarqueeIntro(),setTimeout(function(){this.setupHeader(),this.setupBody(),this.startScrollPromotion(),this.syncScrolling()}.bind(this),200)},setupHeader:function(){Reveal.addEventListener("ready",function(){$(".marquee .browser").addClass("loaded")}),Reveal.initialize({width:700,height:438,loop:!0,progress:!1,keyboard:!1,hideInactiveCursor:!1,autoAnimateMatcher:SL.deck.AutoAnimate.matcher,transition:"slide",backgroundTransition:"fade",controlsLayout:"edges",controlsTutorial:!1,autoSlide:4e3,margin:0}),SL.keyboard.keydown(function(t){if(this.presentationIsInView){if(37===t.keyCode)return Reveal.left(),Reveal.toggleAutoSlide(!1),!1;if(39===t.keyCode||32===t.keyCode)return Reveal.right(),Reveal.toggleAutoSlide(!1),!1}return!0}.bind(this)),SL.deck.Controller.init()},setupBody:function(){(SL.util.device.IS_PHONE||SL.util.device.IS_TABLET)&&$(".feature video").each(function(){$(this).prop("controls",!0),SL.util.device.IS_TABLET&&$(this).prop("autoplay",!0)}),$(".feature").each(function(t,e){e=$(e),video=e.find("video"),video.length&&(SL.util.device.IS_PHONE||SL.util.device.IS_TABLET?(e.addClass("loaded"),this.loadFeatureAnimation(e)):video.on("loadeddata",function(){e.addClass("loaded"),e.hasClass("playing")&&this.startFeatureAnimation(e)}.bind(this)))}.bind(this))},bind:function(){this.learnMoreButton.on("click",this.onLearnMoreClicked.bind(this)),this.scrollPromotion.on("click",this.onLearnMoreClicked.bind(this)),this.scrollPromotionArrow.on("mouseover",this.onScrollPromotionOver.bind(this)),this.syncScrolling=$.throttle(this.syncScrolling,300),this.trackScrolling=$.throttle(this.trackScrolling,500),$(window).on("resize",this.onWindowResize.bind(this)),$(window).on("scroll",this.onWindowScroll.bind(this))},runMarqueeIntro:function(){$(".marquee").addClass("intro");var t=document.querySelector(".marquee-background .path-1"),e=document.querySelector(".marquee-background .path-2"),i=document.querySelector(".marquee-background .path-3");t&&e&&i&&(setTimeout(function(){$({progress:0}).animate({progress:1},{duration:900,easing:"easeInOutQuint",step:function(e){var i=500+-20*e,n=500,s=500+-80*e;t.setAttribute("d","M0,400 L 1000,400 1000,"+i+" S "+n+","+s+" 0,"+i+" Z")}})}.bind(this),200),setTimeout(function(){$({progress:0}).animate({progress:1},{duration:1e3,easing:"easeInOutQuint",step:function(t){var i=500+-20*t,n=500,s=500+-80*t,o=500+-55*t;e.setAttribute("d","M0,400 L 1000,400 1000,"+o+" S "+n+","+s+" 0,"+i+" Z")}})}.bind(this),100),setTimeout(function(){$({progress:0}).animate({progress:1},{duration:1100,easing:"easeInOutQuint",step:function(t){var e=500+-20*t,n=500,s=500+-80*t,o=500+-100*t;i.setAttribute("d","M0,399 L 1000,399 1000,"+o+" S "+n+","+s+" 0,"+e+" Z")}})}.bind(this),0))},trackScrolling:function(){this.scrollTracking=this.scrollTracking||{};var t=$(window).scrollTop(),e=window.innerHeight,i=$(document).height(),n=Math.max(Math.min(t/(i-e),1),0);n>.1&&!this.scrollTracking[.1]&&(this.scrollTracking[.1]=!0,SL.analytics.track("Home: Scrolled","10%")),n>.5&&!this.scrollTracking[.5]&&(this.scrollTracking[.5]=!0,SL.analytics.track("Home: Scrolled","50%")),n>.95&&!this.scrollTracking[.95]&&(this.scrollTracking[.95]=!0,SL.analytics.track("Home: Scrolled","100%"))},syncScrolling:function(){var t=$(window).scrollTop();if(!SL.util.device.IS_PHONE&&!SL.util.device.IS_TABLET){var e=window.innerHeight;this.presentationIsInView=t<.3*e,$(".feature").each(function(t,i){i=$(i);var n=i.get(0).getBoundingClientRect(),s=i.hasClass("playing"),o=i.hasClass("loaded"),a=0===t?-20:100;!o&&n.bottom>-200&&n.top<e+a&&this.loadFeatureAnimation(i),n.top+n.height/2>0&&n.top+n.height/2<e?s||this.startFeatureAnimation(i):s&&this.stopFeatureAnimation(i)}.bind(this))}t>20&&(this.scrollPromotion.addClass("hidden"),this.postersLoaded||(this.postersLoaded=!0,$(".feature video").each(function(){this.setAttribute("poster",this.getAttribute("data-poster"))})))},loadFeatureAnimation:function(t){var e=t.find("video");if(e.length){var i=e.find("span[data-src]");if(i.length){var n="";e.find("span[data-src]").each(function(t,e){e=$(e),n+='<source src="'+e.attr("data-src")+'" type="'+e.attr("data-type")+'">'}),n&&e.html(n)}}},startFeatureAnimation:function(t){t.addClass("playing");var e=t.find("video").get(0);e&&t.hasClass("loaded")&&e.play()},stopFeatureAnimation:function(t){t.removeClass("playing");var e=t.find("video").get(0);e&&t.hasClass("loaded")&&e.pause()},startScrollPromotion:function(){clearInterval(this.scrollPromotionInterval),this.scrollPromotionInterval=setInterval(this.promoteScrolling.bind(this),2500)},stopScrollPromotion:function(){clearInterval(this.scrollPromotionInterval),this.scrollPromotionInterval=null},promoteScrolling:function(){this.scrollPromotionArrow.removeClass("bounce"),setTimeout(function(){this.scrollPromotionArrow.addClass("bounce")}.bind(this),1)},onScrollPromotionOver:function(){this.stopScrollPromotion()},onLearnMoreClicked:function(){SL.analytics.track("Home: Learn more clicked"),this.stopScrollPromotion()},onWindowResize:function(){this.syncScrolling()},onWindowScroll:function(){this.scrollPromotionInterval&&this.stopScrollPromotion(),this.syncScrolling(),this.trackScrolling()}}),SL("views.statik").All=SL.views.Base.extend({init:function(){this._super(),$("img.click-to-expand").on("click",function(){$(this).toggleClass("expanded")}),this.setupHighlight()},setupHighlight:function(){$("code").length>0&&"undefined"!=typeof window.hljs&&window.hljs.initHighlighting()}}),SL("views.statik").Pricing=SL.views.statik.All.extend({init:function(){this._super(),this.setupBillingPeriod(),$(".tier").each(this.setupTier.bind(this));var t=SL.util.getQuery();t&&"string"==typeof t.highlight&&this.highlightTier(t.highlight),this.syncBillingPeriod()},setupBillingPeriod:function(){this.monthlyBillingButton=$("#monthly-billing"),this.yearlyBillingButton=$("#yearly-billing"),$(".billing-period input[type=radio]").on("click",this.syncBillingPeriod.bind(this))},syncBillingPeriod:function(){$(".tier .pricing-counter").stop(!0,!1).each(function(){this.textContent=this.innerText.trim()});var t=$("html").attr("data-billing-period"),e=$(".billing-period input[type=radio]:checked").val();$("html").attr("data-billing-period",e),$(".cta a").each(function(){var t=this;t.hasAttribute("data-original-href")||t.setAttribute("data-original-href",t.getAttribute("href"));var i=t.getAttribute("data-original-href");i+=i.indexOf("?")===-1?"?":"&",i+="period="+e,t.setAttribute("href",i)}),e!==t&&($(".tier .pricing-counter").each(function(){"monthly"===e?SL.util.anim.countTo(this,parseFloat(this.innerText.trim()),parseFloat(this.getAttribute("data-monthly-value"))):SL.util.anim.countTo(this,parseFloat(this.innerText.trim()),parseFloat(this.getAttribute("data-yearly-value")))}),$(".tier header .description").each(function(){$(this).removeClass("flash"),SL.util.dom.calculateStyle($(this)),$(this).addClass("flash")}))},setupTier:function(t,e){var e=$(e),i=e.find(".cta a");i.length&&!i.hasClass("disabled")&&(e.on("click",function(t){t.preventDefault(),window.location=i.attr("href")}),e.on("mouseenter",function(){e.addClass("hover")}),e.on("mouseleave",function(){e.removeClass("hover")}))},highlightTier:function(t){var e=".tier."+t.split("-").join(", .tier."),i=$(e);if(i.length){i.addClass("emphasize"),$(".tier").not(i).addClass("deemphasize"),$(".pricing-header").addClass("deemphasize");var n=i.first();n.offset().top>window.innerHeight+$(window).scrollTop()&&$(window).scrollTop(n.offset().top-50)}}}),SL("views.subscriptions").EditPeriod=SL.views.Base.extend({init:function(){this._super(),Ladda.bind($("#payment-form button[type=submit]").get(0))}}),SL("views.subscriptions").New=SL.views.Base.extend({init:function(){this._super(),this.onFormSubmit=this.onFormSubmit.bind(this),this.onStripeResponse=this.onStripeResponse.bind(this),this.formElement=$("#payment-form"),this.formElement.on("submit",this.onFormSubmit),this.formSubmitButton=this.formElement.find("button[type=submit]"),this.formSubmitLoader=Ladda.create(this.formSubmitButton.get(0)),this.isCCForm=$("#stripe-card-number, #stripe-card-cvc").length>0,$("#stripe-card-number").payment("formatCardNumber"),$("#stripe-card-cvc").payment("formatCardCVC"),SL.util.device.supportedByEditor()||$(".column").prepend("<section class=\"critical-error\"><h2>Not supported</h2><p>It looks like you're using a browser which isn't suported by the Slides editor. Please make sure to try the editor before upgrading.</p></section>"),$("html").hasClass("subscriptions new")&&($('input[name="subscription[billing_period]"]').on("change",this.syncSubmitButton.bind(this)),this.syncSubmitButton())},syncSubmitButton:function(){var t=this.formElement.find('input[name="subscription[billing_period]"]:checked'),e=t.attr("data-period-value"),i=t.attr("data-usd-value"),n=this.formElement.find(".devise-note:not(.disabled)");e&&i?n.html("You are starting a <strong>"+e+"</strong> subscription and will be charged <strong>$"+i+"</strong> today.").removeClass("hidden"):n.addClass("hidden")},onFormSubmit:function(t){if(this.formSubmitLoader.start(),this.isCCForm)return Stripe.createToken(this.formElement,this.onStripeResponse),t.preventDefault(),!1},onStripeResponse:function(t,e){if(e.error)SL.notify(e.error.message,"negative"),this.formSubmitLoader.stop();else{var i=e.id;this.formElement.find('input[name="subscription[token]"]').remove(),this.formElement.append($('<input type="hidden" name="subscription[token]" />').val(i)),this.formElement.get(0).submit()}}}),SL("views.subscriptions").Show=SL.views.Base.extend({DOTTED_CARD_PREFIX:"&bull;&bull;&bull;&bull; ",init:function(){this._super(),this.strings={CONFIRM_UNSUBSCRIBE_ACTION:"Cancel subscription",CONFIRM_UNSUBSCRIBE_DESCRIPTION:SL.locale.get("DOWNGRADE_TO_FREE_CONFIRM")};var t=window.SLCurrentUserPublicDeckCount;"number"==typeof t&&t>0&&(this.strings.CONFIRM_UNSUBSCRIBE_DESCRIPTION+="<br><br>Note that you have <strong>"+t+" public "+SL.util.string.pluralize("deck","s",t>1)+"</strong>. After downgrading to Free, those public pages will begin showing ads."),this.load().then(this.onDataLoaded.bind(this),this.onDataFailed.bind(this))},bindLadda:function(){$(".column section .ladda-button").each(function(t,e){e=$(e),e.data("ladda")||e.data("ladda",Ladda.create(e.get(0)))})},load:function(){return Promise.all([this.loadAccountDetails(),this.loadSubscriptionDetails()])},loadAccountDetails:function(){return $.ajax({url:SL.endpoints.ACCOUNT_DETAILS,type:"GET",context:this}).done(function(t){this.data=new SL.models.Customer(t.customer)})},loadSubscriptionDetails:function(){return new Promise(function(t){$.ajax({url:SL.endpoints.SUBSCRIPTION_DETAILS,type:"GET",context:this}).done(function(t){this.subscriptionDetails=t}).always(function(){t()})}.bind(this))},onDataLoaded:function(){this.render()},onDataFailed:function(){$(".billing-loader").text(SL.locale.get("BILLING_DETAILS_ERROR"))},render:function(){$(".billing-loader").remove(),this.renderDetails(),this.renderHistory(),(!SL.current_user.isEnterprise()||SL.current_user.billing_address||SL.current_user.billing_vat_id)&&this.renderBusinessDetails(),this.bindLadda()},renderDetails:function(){var t=$('<section class="billing-details"><h2>Billing details</h2></section>').appendTo(".billing-wrapper"),e=this.data.hasActiveSubscription();if(e){if(t.append('<div class="field status"><span class="label">Status</span><span class="value">Active</span></div>'),t.append('<div class="field"><span class="label">Plan</span><span class="value">'+SL.util.string.toTitleCase(this.subscriptionDetails.plan.tier)+"</span></div>"),this.data.has("active_card")&&t.append('<div class="field card"><span class="label">Card</span><span class="value">'+this.DOTTED_CARD_PREFIX+this.data.get("active_card.last4")+"</span></div>"),t.append('<div class="field"><span class="label">Billing period</span><span class="value">'+(this.subscriptionDetails.billed_yearly?"Yearly":"Monthly")+"</span></div>"),this.data.hasActiveSubscription()&&this.data.hasCoupon()){var i=this.data.get("subscription.coupon_code").toUpperCase(),n=this.data.get("subscription.percent_off");n>0&&(i+=" / "+n+"% off"),t.append('<div class="field"><span class="label">Coupon</span><span class="value">'+i+"</span></div>")}if(this.data.has("subscription")){var s=moment.unix(this.data.getNextInvoiceDate()).format("MMMM Do, YYYY"),o="$"+this.data.getNextInvoiceSum();t.append('<div class="field payment-cycle"><span class="label">Next invoice</span><span class="value">'+o+" on "+s+"</span></div>")}t.append('<footer class="actions"><a class="button outline thin" href="'+SL.routes.SUBSCRIPTIONS_EDIT_CARD+'">Change credit card</a><button class="button negative outline thin cancel-subscription ladda-button" data-style="expand-right" data-spinner-color="#222">'+this.strings.CONFIRM_UNSUBSCRIBE_ACTION+"</button></footer>"),this.data.get("can_change_period")&&t.find(".actions").prepend('<a class="button outline thin" href="'+SL.routes.SUBSCRIPTIONS_EDIT_PERIOD+'">Switch to annual billing</a>'),t.find(".actions").prepend('<a class="button outline thin" href="'+SL.routes.PRICING+'">Upgrade</a>'),t.find(".actions").prepend('<p class="title">Options</p>')}else{var a="No active subscription",r=this.data.has("subscription");r&&(a=SL.util.string.toTitleCase(this.subscriptionDetails.plan.tier)+" until "+moment.unix(this.data.get("subscription.current_period_end")).format("MMM Do, YYYY")),t.append('<div class="field status"><span class="label">Status</span><span class="value">'+a+"</span></div>"),r?t.append('<footer class="actions"><button class="button outline thin positive reactivate-subscription ladda-button" data-style="expand-right" data-spinner-color="#222">Reactivate subscription</button></footer>'):t.append('<footer class="actions"><a class="button outline thin positive" href="'+SL.routes.PRICING+'">Upgrade</a></footer>'),this.reactivateButton=$(".billing-details .reactivate-subscription"),this.reactivateButton.length&&(this.reactivateButton.on("click",this.onReactivateSubscriptionClicked.bind(this)),this.reactivateLoader=Ladda.create(this.reactivateButton.get(0)))}this.cancelButton=$(".billing-details .cancel-subscription"),this.cancelButton.length&&(this.cancelButton.on("click",this.onCancelSubscriptionClicked.bind(this)),this.cancelLoader=Ladda.create(this.cancelButton.get(0)))},renderHistory:function(){var t=$(['<section class="billing-history">',"<h2>Payments</h2>",'<table class="sl-table"></table>',"</section>"].join("")).appendTo(".billing-wrapper"),e=t.find("table");if(this.data.get("can_toggle_notifications")===!0){t.append(['<div class="sl-checkbox outline">','<input type="checkbox" id="receipt-notifications">','<label for="receipt-notifications">Send receipts via email when I\'m charged</label>',"</div>"].join(""));var i=t.find("#receipt-notifications");i.on("change",this.onEmailNotificationChanged.bind(this)),SL.current_user.notify_on_receipt&&i.prop("checked",!0)}e.html(["<tr>",'<th class="amount">Amount</th>','<th class="date">Date</th>','<th class="card">Card</th>','<th class="download">Download</th>',"</tr>"].join(""));var n=this.data.get("charges");n&&n.length?n.forEach(function(t){if(t.paid){var i=t.amount_refunded>0?'<span class="refund">-$'+(t.amount_refunded/100).toFixed(2)+"</span>":"",n=$(['<tr data-charge-id="'+t.id+'">','<td class="amount">$'+(t.amount/100).toFixed(2)+i+"</td>",'<td class="date">'+moment.unix(t.created).format("DD-MM-YYYY")+"</td>",'<td class="card">'+this.DOTTED_CARD_PREFIX+t.card.last4+"</td>",'<td class="download">','<form action="'+SL.endpoints.SUBSCRIPTIONS_PRINT_INVOICE(t.id)+'" method="post">','<button type="submit" class="button outline thin ladda-button download-button" data-style="slide-right" data-spinner-color="#222">',"Invoice","</button>","</form>",'<form action="'+SL.endpoints.SUBSCRIPTIONS_PRINT_RECEIPT(t.id)+'" method="post">','<button type="submit" class="button outline thin ladda-button download-button" data-style="slide-right" data-spinner-color="#222">',"Receipt","</button>","</form>","</td>","</tr>"].join(""));n.appendTo(e),SL.util.dom.insertCSRF(n.find(".download form"))}}.bind(this)):e.replaceWith("<p>"+SL.locale.get("BILLING_DETAILS_NOHISTORY")+"</p>");
},renderBusinessDetails:function(){var t=$(['<section class="billing-business-details">',"<h2>Business info</h2>",'<div class="sl-form">','<div class="unit">',"<label>Billing address</label>",'<p class="unit-description">Enter a billing address to include it on your receipts.</p>','<textarea class="business-address-input" rows="4" maxlength="300">',SL.current_user.billing_address||"","</textarea>","</div>",'<div class="unit">',"<label>VAT ID</label>",'<p class="unit-description">Enter a VAT ID to include it on your receipts.</p>','<input class="business-vat-input" type="text" maxlength="50" value="'+(SL.current_user.billing_vat_id||"")+'" />',"</div>",'<div class="footer">','<button class="button l positive business-save-business">Save changes</button>',"</div>","</div>","</section>"].join("")).appendTo(".billing-wrapper");this.businessAddressInput=t.find(".business-address-input"),this.businessVATInput=t.find(".business-vat-input"),this.businessSaveButton=t.find(".business-save-business"),this.businessAddressInput.on("change keyup mouseup",this.checkBusinessDetails.bind(this)),this.businessVATInput.on("change keyup mouseup",this.checkBusinessDetails.bind(this)),this.businessSaveButton.on("click",this.saveBusinessDetails.bind(this)),this.businessSaveButton.hide()},checkBusinessDetails:function(){var t=this.businessAddressInput.val()!==(SL.current_user.billing_address||""),e=this.businessVATInput.val()!==(SL.current_user.billing_vat_id||"");t||e?this.businessSaveButton.show():this.businessSaveButton.hide()},saveBusinessDetails:function(){this.businessDetailsXHR&&this.businessDetailsXHR.abort();var t=this.businessAddressInput.val()||"",e=this.businessVATInput.val();this.businessDetailsXHR=$.ajax({url:SL.endpoints.UPDATE_USER,type:"PUT",context:this,data:{user:{billing_address:t,billing_vat_id:e}}}).done(function(){SL.current_user.billing_address=t,SL.current_user.billing_vat_id=e,SL.notify("Business details saved")}).fail(function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative")}).always(function(){this.businessDetailsXHR=null,this.checkBusinessDetails()})},onCancelSubscriptionClicked:function(){this.unsubscribePrompt||(this.unsubscribePrompt=new SL.components.prompts.Unsubscribe({footnote:this.strings.CONFIRM_UNSUBSCRIBE_DESCRIPTION}),this.unsubscribePrompt.show(),this.unsubscribePrompt.confirmed.add(function(t){this.cancelLoader.start(),$.ajax({url:SL.endpoints.SUBSCRIPTIONS,type:"DELETE",context:this,data:{cancellation:t}}).done(this.onCancelSubscriptionSuccess).fail(this.onCancelSubscriptionError)}.bind(this)),this.unsubscribePrompt.destroyed.add(function(){this.unsubscribePrompt=null}.bind(this)))},onCancelSubscriptionSuccess:function(){SL.notify(SL.locale.get("DOWNGRADE_TO_FREE_SUCCESS")),window.location.reload()},onCancelSubscriptionError:function(){SL.notify(SL.locale.get("GENERIC_ERROR")),this.cancelLoader.stop()},onReactivateSubscriptionClicked:function(t){SL.prompt({anchor:$(t.currentTarget),title:"Are you sure you want to reactivate your subscription?",type:"select",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Reactivate</h3>",selected:!0,className:"positive",callback:function(){this.reactivateLoader.start(),$.ajax({url:SL.endpoints.SUBSCRIPTIONS_REACTIVATE,type:"PUT",context:this}).done(this.onReactivateSubscriptionSuccess).fail(this.onReactivateSubscriptionError)}.bind(this)}]})},onReactivateSubscriptionSuccess:function(){SL.notify("Subscription reactivated!"),window.location.reload()},onReactivateSubscriptionError:function(){SL.notify(SL.locale.get("GENERIC_ERROR")),this.cancelLoader.stop()},onEmailNotificationChanged:function(t){this.emailNotificationXHR&&this.emailNotificationXHR.abort();var e=$(t.currentTarget).is(":checked");this.emailNotificationXHR=$.ajax({url:SL.endpoints.UPDATE_USER,type:"PUT",context:this,data:{user:{notify_on_receipt:e}}}).done(function(){e===!0?SL.notify("Got it. We'll email receipts to you"):SL.notify("Receipts will no longer be emailed")}).fail(function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative")}).always(function(){this.emailNotificationXHR=null})}}),SL("views.teams").New=SL.views.Base.extend({init:function(){this._super(),this.formElement=$("#payment-form"),this.formSubmitButton=this.formElement.find("button[type=submit]"),this.formSubmitLoader=Ladda.create(this.formSubmitButton.get(0)),this.formTermsCheckbox=$("#terms_agreement"),this.bind(),this.summarize()},bind:function(){this.summarize=this.summarize.bind(this),this.formElement.on("keydown",this.onFormKeyDown.bind(this)),this.formSubmitButton.on("click",this.onFormSubmitClicked.bind(this)),this.formElement.find("#team-name").on("input",this.onTeamNameChange.bind(this)),this.formElement.find('input[name="billing-period"]').on("change",this.onBillingPeriodChanged.bind(this)),$("#stripe-card-number").payment("formatCardNumber"),$("#stripe-card-cvc").payment("formatCardCVC"),$("#stripe-month").payment("restrictNumeric"),$("#stripe-year").payment("restrictNumeric"),this.formElement.find(".unit[data-validate], .unit[data-required]").each(function(t,e){new SL.components.FormUnit(e)}),this.formTermsCheckbox.length&&this.formTermsCheckbox.on("change",function(){this.syncSubmitButton()}.bind(this)),this.syncSubmitButton()},syncSubmitButton:function(){0===this.formTermsCheckbox.length||this.formTermsCheckbox.is(":checked")?this.formSubmitButton.removeAttr("disabled").removeAttr("data-tooltip").removeClass("disabled"):this.formSubmitButton.attr("disabled","disabled").addClass("disabled")},summarize:function(){var t=this.formElement.find(".purchase-summary");this.billingPeriod="monthly"===this.formElement.find('input[name="billing-period"]:checked').val()?"monthly":"yearly",t.attr("data-period",this.billingPeriod)},validate:function(){var t=!0;return this.formElement.find(".unit[data-validate], .unit[data-required]").each(function(e,i){var n=$(i).data("controller");n.validate(!0)===!1&&(t&&n.focus(),t=!1)}),this.formTermsCheckbox.length&&this.formTermsCheckbox.is(":checked")===!1&&(SL.notify("Please agree to the Terms of Service and Privacy policy before proceeding."),t=!1),t},captureData:function(){this.formData={team:{name:this.formElement.find("#team-name").val(),slug:this.formElement.find("#team-slug").val()},user:{username:this.formElement.find("#user-name").val(),email:this.formElement.find("#user-email").val(),password:this.formElement.find("#user-password").val()},subscription:{billing_period:this.formElement.find('input[name="billing-period"]:checked').val(),coupon:this.formElement.find('input[name="coupon"]').val()}}},submitToStripe:function(){this.validate()&&(this.captureData(),this.formSubmitLoader.start(),SL.current_user&&SL.current_user.isPaid()&&0===$("#stripe-card-number").length?this.submitToApp():Stripe.createToken(this.formElement,this.onStripeResponse.bind(this)))},submitToApp:function(t){t&&(this.formData.subscription.token=t),$.ajax({type:"POST",url:SL.endpoints.TEAMS_CREATE,data:JSON.stringify(this.formData),dataType:"json",context:this,contentType:"application/json"}).done(function(t){t.team&&"string"==typeof t.team.root_url?window.location=window.location.protocol+"//"+t.team.root_url:window.location=window.location.protocol+"//"+this.formData.team.slug+"."+window.location.host}).fail(function(t){var e=SL.locale.get("GENERIC_ERROR"),i=JSON.parse(t.responseText);i&&(i.user&&i.user.email&&i.user.email.length?e="Email error: "+i.user.email[0]:i.team&&i.team.name&&i.team.name.length?e="Team name error: "+i.team.name[0]:i.team&&i.team.slug&&i.team.slug.length&&(e="Team name error: "+i.team.slug[0])),SL.notify(e,"negative"),this.formSubmitLoader.stop()})},onStripeResponse:function(t,e){e.error?(SL.notify(e.error.message,"negative"),this.formSubmitLoader.stop()):this.submitToApp(e.id)},onFormKeyDown:function(t){if(13===t.keyCode)return this.submitToStripe(),t.preventDefault(),!1},onFormSubmitClicked:function(t){return this.submitToStripe(),t.preventDefault(),!1},onTeamNameChange:function(){var t=this.formElement.find("#team-name"),e=this.formElement.find("#team-slug");e.val(SL.util.string.slug(t.val()));var i=e.parent(".unit").data("controller");i&&i.validateAfterTimeout()},onBillingPeriodChanged:function(){this.summarize(),Modernizr.history&&window.history.replaceState(null,null,window.location.pathname+"?period="+this.billingPeriod)}}),SL("views.teams.subscriptions").Reactivate=SL.views.Base.extend({init:function(){this._super(),this.formElement=$("#payment-form"),this.formSubmitButton=this.formElement.find("button[type=submit]"),this.formSubmitLoader=Ladda.create(this.formSubmitButton.get(0)),this.bind(),this.summarize()},bind:function(){this.summarize=this.summarize.bind(this),this.formElement.on("keydown",this.onFormKeyDown.bind(this)),this.formSubmitButton.on("click",this.onFormSubmitClicked.bind(this)),this.formElement.find('input[name="billing-period"]').on("change",this.summarize),$("#stripe-card-number").payment("formatCardNumber"),$("#stripe-card-cvc").payment("formatCardCVC"),$("#stripe-month").payment("restrictNumeric"),$("#stripe-year").payment("restrictNumeric")},summarize:function(){var t=this.formElement.find(".purchase-summary"),e="monthly"===this.formElement.find('input[name="billing-period"]:checked').val();t.attr("data-period",e?"monthly":"yearly")},submitToStripe:function(){this.formSubmitLoader.start(),Stripe.createToken(this.formElement,this.onStripeResponse.bind(this))},submitToApp:function(t){var e={subscription:{token:t,billing_period:this.formElement.find('input[name="billing-period"]:checked').val()}};$.ajax({type:"POST",url:SL.endpoints.TEAMS_REACTIVATE,data:JSON.stringify(e),dataType:"json",context:this,contentType:"application/json"}).done(function(t){t.team&&"string"==typeof t.team.root_url?window.location=window.location.protocol+"//"+t.team.root_url:window.location="/"}).fail(function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative"),this.formSubmitLoader.stop()})},onStripeResponse:function(t,e){e.error?(SL.notify(e.error.message,"negative"),this.formSubmitLoader.stop()):this.submitToApp(e.id)},onFormKeyDown:function(t){if(13===t.keyCode)return this.submitToStripe(),t.preventDefault(),!1},onFormSubmitClicked:function(t){return this.submitToStripe(),t.preventDefault(),!1}}),SL("views.teams.subscriptions").Show=SL.views.subscriptions.Show.extend({init:function(){this._super()},render:function(){this.data.isTrial()?(this.strings.CONFIRM_UNSUBSCRIBE_ACTION="Cancel subscription and deactivate my team",this.strings.CONFIRM_UNSUBSCRIBE_DESCRIPTION="Your trial will be canceled immediately and this team will no longer be accessible."):(this.strings.CONFIRM_UNSUBSCRIBE_ACTION="Cancel subscription and deactivate my team",this.strings.CONFIRM_UNSUBSCRIBE_DESCRIPTION="Your subscription will be cancelled and this team will no longer be accessible after the end of the current billing cycle."),this._super()},renderDetails:function(){var t=$('<section class="billing-details"><h2>Billing details</h2></section>').appendTo(".billing-wrapper"),e=this.data.hasActiveSubscription(),i=this.data.isTrial();if(e){if(i?t.append('<div class="field status"><span class="label">Status</span><span class="value">Trial</span></div>'):t.append('<div class="field status"><span class="label">Status</span><span class="value">Active</span></div>'),SL.current_team.has("user_count")&&t.append('<div class="field active-users"><span class="label" data-tooltip="The current number of users that you have invited to the team." data-tooltip-maxwidth="260">Team members</span><span class="value">'+SL.current_team.get("user_count")+"</span></div>"),this.data.has("subscription.period")&&t.append('<div class="field period"><span class="label">Billing period</span><span class="value">'+("year"===this.data.get("subscription.period")?"Yearly":"Monthly")+"</span></div>"),this.data.has("active_card")&&t.append('<div class="field card"><span class="label">Card</span><span class="value">'+this.DOTTED_CARD_PREFIX+this.data.get("active_card.last4")+"</span></div>"),this.data.hasActiveSubscription()&&this.data.hasCoupon()){var n=this.data.get("subscription.coupon_code").toUpperCase(),s=this.data.get("subscription.percent_off");s>0&&(n+=" / "+s+"% off"),t.append('<div class="field"><span class="label">Coupon</span><span class="value">'+n+"</span></div>")}if(this.data.has("subscription")){var o=moment.unix(this.data.getNextInvoiceDate()).format("MMMM Do, YYYY"),a=i?"First invoice":"Next invoice",r="$"+this.data.getNextInvoiceSum();t.append('<div class="field payment-cycle"><span class="label">'+a+'</span><span class="value">'+r+" on "+o+"</span></div>")}t.append('<footer class="actions"><a class="button outline thin" href="'+SL.routes.SUBSCRIPTIONS_EDIT_CARD+'">Change credit card</a><button class="button negative outline thin cancel-subscription ladda-button" data-style="expand-right" data-spinner-color="#222">'+this.strings.CONFIRM_UNSUBSCRIBE_ACTION+"</button></footer>"),this.data.get("can_change_period")&&t.find(".actions").prepend('<a class="button outline thin" href="'+SL.routes.SUBSCRIPTIONS_EDIT_PERIOD+'">Switch to annual billing</a>'),t.find(".actions").prepend('<p class="title">Options</p>')}else{var l="No active subscription",d=this.data.has("subscription");d&&(l="Canceled, available until "+moment.unix(this.data.get("subscription.current_period_end")).format("MMM Do, YYYY")),t.append('<div class="field status"><span class="label">Status</span><span class="value">'+l+"</span></div>"),SL.current_team.has("user_count")&&t.append('<div class="field active-users"><span class="label" data-tooltip="The current number of users that you have invited to the team." data-tooltip-maxwidth="260">Team members</span><span class="value">'+SL.current_team.get("user_count")+"</span></div>"),this.data.has("active_card")&&t.append('<div class="field card"><span class="label">Card</span><span class="value">'+this.DOTTED_CARD_PREFIX+this.data.get("active_card.last4")+"</span></div>")}this.cancelButton=$(".billing-details .cancel-subscription"),this.cancelButton.length&&(this.cancelButton.on("click",this.onCancelSubscriptionClicked.bind(this)),this.cancelLoader=Ladda.create(this.cancelButton.get(0)))},onCancelSubscriptionSuccess:function(){SL.notify("Subscription canceled"),window.location="http://slides.com"}}),SL("views.teams.teams").Edit=SL.views.Base.extend({init:function(){this._super(),this.render()},render:function(){if(this.formElement=$("form"),this.formElement.length){this.formElement.find(".unit[data-factory]").each(function(t,e){var i=null;$(e).attr("data-factory").split(".").forEach(function(t){i=i?i[t]:window[t]}),"function"==typeof i&&new i(e)}),this.formElement.find(".unit[data-validate]:not([data-factory])").each(function(t,e){new SL.components.FormUnit(e)});var t=this.formElement.find("button[type=submit]");if(t.length){var e=Ladda.create(t.get(0));this.formElement.on("submit",function(t){t.isDefaultPrevented()||e.start()}.bind(this))}}}}),SL("views.teams.teams").EditMembers=SL.views.Base.extend({init:function(){this._super(),this.strings={loadMoreMembers:"Load more",loadingMoreMembers:"Loading..."},this.render(),this.bind(),this.load().then(this.afterLoad.bind(this),function(){this.preloaderElement.remove(),this.contentElement.html("<strong>Sorry but we ran into an issue. Try reloading the page.</strong>").show()}.bind(this))},render:function(){this.preloaderElement=$(".users-preloader"),this.contentElement=$(".users-content"),this.activeMembersTable=this.contentElement.find(".users-group-active-members tbody"),this.inactiveMembersTable=this.contentElement.find(".users-group-inactive-members tbody"),this.invitesTable=this.contentElement.find(".users-group-invites tbody"),this.inviteDescription=this.contentElement.find(".invite-description"),this.inviteForm=this.contentElement.find(".invite-form"),this.bindLadda(this.inviteForm),this.submitButton=this.inviteForm.find("[type=submit]"),this.emailInput=this.inviteForm.find("[name=email]"),this.roleInput=this.inviteForm.find("[name=role]"),this.loadMoreMembers=$('<div class="load-more">'),this.loadMoreMembers.appendTo(this.contentElement.find(".users-group-active-members")),this.loadMoreMembersLabel=$('<span class="load-more-label"></span>'),this.loadMoreMembersLabel.appendTo(this.loadMoreMembers),this.loadMoreMembersButton=$('<button class="load-more-button">'+this.strings.loadMoreMembers+"</button>"),this.loadMoreMembersButton.on("vclick",this.onLoadMoreMembersClicked.bind(this)),this.loadMoreMembersButton.appendTo(this.loadMoreMembers)},bind:function(){this.inviteForm.on("submit",this.onInviteSubmit.bind(this)),this.emailInput.on("input",this.onEmailInput.bind(this))},bindLadda:function(t){t.find(".ladda-button").each(function(t,e){e=$(e),e.data("ladda")||e.data("ladda",Ladda.create(e.get(0)))})},load:function(){return this.membersCollection=new SL.collections.TeamMembers,this.invitesCollection=new SL.collections.TeamInvites,Promise.all([this.loadSubscriptionDetails(),this.membersCollection.load(),this.invitesCollection.load()])},loadSubscriptionDetails:function(){return $.ajax({url:SL.endpoints.SUBSCRIPTION_DETAILS,type:"GET",context:this}).done(function(t){this.subscriptionDetails=t})},afterLoad:function(){this.preloaderElement.remove(),this.contentElement.show(),this.membersCollection.forEach(this.renderMember.bind(this)),this.invitesCollection.forEach(this.renderInvitee.bind(this)),this.refreshLoadMore(),this.refreshTableVisibility(),this.refreshInviteDescription()},refreshLoadMore:function(){this.loadMoreMembers.toggleClass("visible",!this.membersCollection.isLoading()&&this.membersCollection.isLoaded()&&this.membersCollection.hasNextPage()),this.loadMoreMembersLabel.text("Showing "+this.membersCollection.getLoadedResults()+"/"+this.membersCollection.getTotalResults()+" members")},refreshTableVisibility:function(){this.activeMembersTable.parents(".users-group").toggleClass("visible",this.getActiveMemberCount()>0),this.inactiveMembersTable.parents(".users-group").toggleClass("visible",this.getInactiveMemberCount()>0),this.invitesTable.parents(".users-group").toggleClass("visible",this.getInvitedMemberCount()>0)},refreshInviteDescription:function(){var t="";this.subscriptionDetails.manually_upgraded?t="Invited members will receive instructions via email.":this.subscriptionDetails.free_invites_remaining>0?t='Invited members will receive instructions via email. <span class="badge">'+this.subscriptionDetails.free_invites_remaining+" free "+SL.util.string.pluralize("invite","s",this.subscriptionDetails.free_invites_remaining>1)+" remaining</span>":this.subscriptionDetails.billed_yearly?t="They'll receive instructions via email. You will be charged the prorated amount for the remainder of your current yearly billing cycle. At the start of your next billing cycle you are charged <strong>$"+this.subscriptionDetails.price_per_account+" per team member</strong>.":this.subscriptionDetails.billed_monthly&&(t="They'll receive instructions via email. You will be charged the prorated amount for the remainder of your current monthly billing cycle. At the start of your next billing cycle you are charged <strong>$"+this.subscriptionDetails.price_per_account+" per team member</strong>."),this.inviteDescription.html(t)},refreshInviteDescriptionAfterReload:function(){this.loadSubscriptionDetails().then(this.refreshInviteDescription.bind(this))},renderMember:function(t){t.hasMembership()&&t.membership.get("activated")?this.renderActiveMember(t):this.renderInactiveMember(t)},renderActiveMember:function(t){var e=$("<tr>").attr("data-id",t.get("id")),i='<div class="avatar" style="background-image: url('+t.get("thumbnail_url")+')" data-tooltip="View profile"></div>';e.append('<td><a class="avatar-link" href="/'+t.get("username")+'" target="_blank">'+i+"</a>"+t.get("email")+"</td>"),e.append('<td class="role"></td>'),e.append('<td class="actions"></td>');var n=this.renderRoleSelector(t,!0);n.appendTo(e.find(".role")),n.on("change",this.onRoleChanged.bind(this,t,e));var s=SL.current_user.get("id")===t.get("id"),o=t.hasMembership()&&t.membership.isOwner();s||o||(e.find(".actions").append('<button class="button outline ladda-button deactivate" data-style="zoom-out" data-spinner-color="#222" data-tooltip="Deactivate"><span class="i-x"></span></button>'),e.find(".deactivate").on("click",this.onDeactivateUserClicked.bind(this,t,e))),e.appendTo(this.activeMembersTable)},renderInactiveMember:function(t){var e=$("<tr>").attr("data-id",t.get("id"));e.append("<td>"+t.get("email")+"</td>"),e.append('<td class="role"></td>'),e.append('<td class="actions"></td>'),e.find(".role").append(this.renderRoleSelector(t,!1)),e.find(".actions").html(['<button class="button outline ladda-button delete" data-style="zoom-out" data-spinner-color="#222" data-tooltip="Delete permanently"><span class="i-trash"></span></button>','<button class="button outline ladda-button reactivate" data-style="zoom-out" data-spinner-color="#222" data-tooltip="Reactivate account"><span class="i-plus"></span></button>'].join("")),e.find(".reactivate").on("click",this.onReactivateUserClicked.bind(this,t,e)),e.find(".delete").on("click",this.onDeleteUserClicked.bind(this,t,e)),e.appendTo(this.inactiveMembersTable)},renderInvitee:function(t){var e=$("<tr>").attr("data-id",t.get("id"));e.append("<td>"+t.get("email")+"</td>"),e.append('<td class="role"></td>'),e.append('<td class="actions"></td>'),e.find(".role").append(this.renderRoleSelector(t,!1)),e.find(".actions").html(['<button class="button outline ladda-button copy-invite" data-tooltip="Copy invite link"><span class="i-link"></span></button>','<button class="button outline ladda-button resend-invite" data-style="zoom-out" data-spinner-color="#222" data-tooltip="Resend invite"><span class="i-mail"></span></button>','<button class="button outline ladda-button delete-invite" data-style="zoom-out" data-spinner-color="#222" data-tooltip="Cancel invite"><span class="i-x"></span></button>'].join("")),e.find(".copy-invite").on("click",this.copyInviteLink.bind(this,t,e)),e.find(".resend-invite").on("click",this.resendInvite.bind(this,t,e)),e.find(".delete-invite").on("click",this.deleteInvite.bind(this,t,e)),e.appendTo(this.invitesTable)},renderRoleSelector:function(t,e){var i=$('<select class="sl-select s role-selector"></select>'),n=SL.models.UserMembership.ROLE_MEMBER;return n=t.hasMembership&&t.hasMembership()?t.membership.get("role"):t.get("team_role"),n===SL.models.UserMembership.ROLE_OWNER?i.append(['<option value="'+SL.models.UserMembership.ROLE_OWNER+'" selected>Owner</option>'].join("")):(i.append(['<option value="'+SL.models.UserMembership.ROLE_MEMBER+'">Member</option>','<option value="'+SL.models.UserMembership.ROLE_ADMIN+'">Admin</option>'].join("")),i.find('[value="'+n+'"]').prop("selected",!0)),e&&SL.current_user.get("id")!==t.get("id")&&n!==SL.models.UserMembership.ROLE_OWNER||i.attr("disabled",!0),i},onRoleChanged:function(t,e,i){$.ajax({type:"PUT",url:SL.endpoints.TEAM_MEMBER_UPDATE(t.get("id")),data:{user:{role:i.target.value}},context:this}).done(function(){SL.notify("Role saved")}).fail(function(){SL.notify("Failed to change role","negative")})},deactivateUser:function(t,e){this.bindLadda(e);var i=e.find("button.deactivate").data("ladda");i&&i.start(),$.ajax({type:"DELETE",url:SL.endpoints.TEAM_MEMBER_DEACTIVATE(t.get("id")),context:this}).done(function(){SL.notify("User deactivated"),e.remove(),t.membership.set("activated",!1),this.renderInactiveMember(t),this.refreshTableVisibility(),this.refreshInviteDescriptionAfterReload()}).fail(function(){SL.notify("Failed to deactivate member","negative")}).always(function(){i&&i.stop()})},onDeactivateUserClicked:function(t,e,i){SL.prompt({type:"select",anchor:i.currentTarget,title:"Are you sure you want to deactivate this account?",subtitle:"This person will no longer be able to sign in to Slides. You are not charged for deactivated accounts and can reactivate any time.",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Deactivate</h3>",selected:!0,className:"negative",callback:this.deactivateUser.bind(this,t,e)}]})},reactivateUser:function(t,e){this.bindLadda(e);var i=e.find("button.reactivate").data("ladda");i&&i.start(),$.ajax({type:"POST",url:SL.endpoints.TEAM_MEMBER_REACTIVATE(t.get("id")),context:this}).done(function(){SL.notify("User activated"),e.remove(),t.membership.set("activated",!0),this.renderActiveMember(t),this.refreshTableVisibility(),this.refreshInviteDescriptionAfterReload()}).fail(function(){SL.notify("Failed to activate member","negative")}).always(function(){i&&i.stop()})},onReactivateUserClicked:function(t,e){this.reactivateUser(t,e)},deleteUser:function(t,e,i){this.bindLadda(e);var n=e.find("button.delete").data("ladda");n&&n.start(),$.ajax({type:"DELETE",url:SL.endpoints.TEAM_MEMBER_DELETE(t.get("id")),data:{absorb_decks:i},context:this}).done(function(){SL.notify("User deleted"),e.remove(),this.refreshTableVisibility(),this.refreshInviteDescriptionAfterReload()}).fail(function(){SL.notify("Failed to delete member","negative")}).always(function(){n&&n.stop()})},onDeleteUserClicked:function(t,e,i){SL.prompt({type:"select",anchor:i.currentTarget,title:"Do you want to permanently delete this account?",subtitle:"All settings and slide decks associated with the account will be removed. This can not be undone.",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Delete</h3>",selected:!0,className:"negative",callback:this.deleteUser.bind(this,t,e)},{html:"<h3>Delete but keep decks</h3>",selected:!0,className:"negative",callback:this.deleteUser.bind(this,t,e,!0)}]})},sendInvite:function(){var t=this.emailInput.val().trim(),e=this.roleInput.val();if(t&&t.length>1){var i=this.inviteForm.find(".ladda-button").data("ladda");i&&i.start(),$.ajax({type:"POST",url:SL.endpoints.TEAM_INVITATIONS_CREATE,data:{invitation:{email:t,team_role:e}},context:this}).done(function(t){this.renderInvitee(this.invitesCollection.createModel(t)),this.refreshTableVisibility(),this.refreshInviteDescriptionAfterReload(),this.emailInput.val(""),SL.notify("Invite sent!")}).fail(function(t){var e="Failed to send invite";t&&t.responseJSON&&t.responseJSON.email&&t.responseJSON.email.length>0&&"string"==typeof t.responseJSON.email[0]&&(e=t.responseJSON.email[0]),SL.notify(e,"negative")}).always(function(){i&&i.stop()})}},copyInviteLink:function(t,e){var i=SL.util.copyToClipboard(t.get("invitation_url"));if(i)SL.notify("Invite link copied to clipboard!");else{SL.prompt({anchor:e.find("button.copy-invite"),title:"Invite URL",type:"input",cancelLabel:"Close",confirmButton:!1,data:{value:t.get("invitation_url"),readonly:!0,autoselect:!0,width:500}})}},resendInvite:function(t,e){this.bindLadda(e);var i=e.find("button.resend-invite").data("ladda");i&&i.start(),$.ajax({type:"POST",url:SL.endpoints.TEAM_INVITATIONS_RESEND(t.get("id")),context:this}).done(function(){SL.notify("Invite sent!")}).fail(function(){SL.notify("Failed to send invite","negative")}).always(function(){i&&i.stop()})},deleteInvite:function(t,e){this.bindLadda(e);var i=e.find("button.delete-invite").data("ladda");i&&i.start(),$.ajax({type:"DELETE",url:SL.endpoints.TEAM_INVITATIONS_DELETE(t.get("id")),context:this}).done(function(){SL.notify("Invite deleted"),e.remove(),this.refreshTableVisibility(),this.refreshInviteDescriptionAfterReload()}).fail(function(){SL.notify("Failed to delete invite","negative")}).always(function(){i&&i.stop()})},getActiveMemberCount:function(){return this.activeMembersTable.find("tr").length-1},getInactiveMemberCount:function(){return this.inactiveMembersTable.find("tr").length-1},getInvitedMemberCount:function(){return this.invitesTable.find("tr").length-1},onInviteSubmit:function(t){t.preventDefault(),this.sendInvite()},onEmailInput:function(){this.submitButton.prop("disabled",0==this.emailInput.val().trim().length)},onLoadMoreMembersClicked:function(){this.loadMoreMembersButton.prop("disabled",!0).text(this.strings.loadingMoreMembers),this.membersCollection.loadNextPage().then(function(t){t.forEach(this.renderMember.bind(this))}.bind(this))["catch"](function(){SL.notify("Failed to load members","negative")}.bind(this)).then(function(){this.loadMoreMembersButton.prop("disabled",!1).text(this.strings.loadMoreMembers),this.refreshLoadMore()}.bind(this))}}),SL("views.teams.teams").Show=SL.views.Base.extend({init:function(){this._super(),new SL.components.Search({url:SL.endpoints.SEARCH_TEAM})}}),SL("views.themes").Edit=SL.views.Base.extend({init:function(){this._super(),this.themeData=new SL.collections.Collection,this.listElement=$(".theme-list"),this.editorElement=$(".theme-editor"),this.editorInnerElement=$(".theme-editor-inner"),this.VERSION=parseInt($(".theme-editor").attr("data-editor-version"),10),this.load(),this.bindLadda(),this.setupPreview(),$("body").on("click",".global-css-button",this.onGlobalCSSClicked.bind(this)),$("body").on("click",".create-theme-button",this.onCreateThemeClicked.bind(this)),$(window).on("beforeunload",this.onWindowBeforeUnload.bind(this))},bindLadda:function(){$(".page-wrapper .ladda-button").each(function(t,e){e=$(e),e.data("ladda")||e.data("ladda",Ladda.create(e.get(0)))})},setupPreview:function(){this.previewFrame=$(".preview .preview-frame"),this.previewReloader=$(".preview .preview-reloader"),this.previewReloader.on("click",this.reloadPreview.bind(this)),window.addEventListener("message",function(t){t.data&&"theme-preview-ready"===t.data.type&&this.refreshPreview()}.bind(this))},load:function(){SL.helpers.PageLoader.show({message:"Loading themes"}),$.ajax({type:"GET",url:SL.endpoints.THEMES_LIST,context:this}).done(function(t){this.themeData.clear(),t.results.forEach(function(t){this.themeData.push(new SL.models.Theme(t))}.bind(this))}).fail(function(){SL.notify(SL.locale.get("THEME_LIST_LOAD_ERROR"),"negative")}).always(function(){this.renderList(),SL.helpers.PageLoader.hide()})},renderList:function(){this.listElement.empty(),this.themeData.isEmpty()?this.listElement.html('<p class="theme-list-empty">'+SL.locale.get("THEME_LIST_EMPTY")+"</p>"):(this.themeData.forEach(this.renderListItem.bind(this)),SL.view.parseTimes()),this.updateListDefault(),"function"==typeof window.RevealHighlight&&window.RevealHighlight().hljs.initHighlighting()},renderListItem:function(t,e){e=$.extend({prepend:!1,showDelay:0},e);var i=this.listElement.find('[data-theme-id="'+t.get("id")+'"]');if(i.length?i.find(".theme-list-item-title").text(t.get("name")).attr("title",t.get("name")):(i=$(['<div class="theme-list-item" data-theme-id="'+t.get("id")+'">','<div class="theme-list-item-thumbnail"></div>','<h2 class="theme-list-item-title" title="'+t.get("name")+'">'+t.get("name")+"</h2>",'<div class="theme-list-item-metadata">','<div class="theme-list-item-metadata-field">Created <time class="date" datetime="'+t.get("created_at")+'"></time></div>','<div class="theme-list-item-metadata-field">Updated <time class="ago" datetime="'+t.get("updated_at")+'"></time></div>',"</div>",'<div class="theme-list-item-controls">','<button class="button white l delete" data-tooltip="'+SL.locale.get("THEME_DELETE_TOOLTIP")+'">','<span class="icon i-trash"></span>',"</button>",'<button class="button white l edit" data-tooltip="'+SL.locale.get("THEME_EDIT_TOOLTIP")+'">','<span class="icon i-pen-alt2"></span>',"</button>",'<button class="button white l default" data-tooltip="'+SL.locale.get("THEME_MAKE_DEFAULT_TOOLTIP")+'">','<span class="icon i-checkmark"></span>',"</button>","</div>","</div>"].join("")),e.prepend===!0?i.prependTo(this.listElement):i.appendTo(this.listElement),e.showDelay>0&&(i.hide(),setTimeout(function(){i.show()},e.showDelay))),t.hasThumbnail()){var n=t.get("thumbnail_url");i.find(".theme-list-item-thumbnail").css("background-image",'url("'+n+'")').attr("data-thumb-url",n)}return i.off("click").on("click",function(e){$(e.target).closest(".theme-list-item-controls .delete").length?this.removeTheme(t,null,$(e.target).closest(".theme-list-item-controls .delete")):$(e.target).closest(".theme-list-item-controls .default").length?i.hasClass("default")?this.unmakeDefaultTheme():this.makeDefaultTheme(t):this.editTheme(t)}.bind(this)),i},refreshListItemThumb:function(t){if(t&&t.length){var e=t.find(".theme-list-item-thumbnail"),i=e.attr("data-thumb-url");i&&(i=i+"?"+Math.round(1e4*Math.random()),e.css("background-image",'url("'+i+'")'))}},updateListDefault:function(){this.listElement.find(".theme-list-item").each(function(t,e){e=$(e),e.toggleClass("default",e.attr("data-theme-id")==SL.current_team.get("default_theme_id")),e.find(".theme-list-item-controls .default").attr("data-tooltip",e.hasClass("default")?SL.locale.get("THEME_IS_DEFAULT_TOOLTIP"):SL.locale.get("THEME_MAKE_DEFAULT_TOOLTIP"))})},editTheme:function(t){if(this.panel)return this.panel.close(this.editTheme.bind(this,t)),!1;$("html").addClass("is-editing-theme");
var e={};e=1===this.VERSION?{colors:SL.config.V1.THEME_COLORS,fonts:SL.config.V1.THEME_FONTS,center:!0,rollingLinks:!0}:{colors:SL.config.THEME_COLORS,fonts:SL.config.THEME_FONTS,center:!1,rollingLinks:!1},this.panel=new SL.views.themes.edit.Panel(this,t,e),this.panel.destroyed.add(function(){$("html").removeClass("is-editing-theme"),this.panel=null}.bind(this)),this.bindLadda()},createTheme:function(){$.ajax({type:"POST",url:SL.endpoints.THEMES_CREATE,data:{theme:{font:SL.config.DEFAULT_THEME_FONT,color:SL.config.DEFAULT_THEME_COLOR,transition:SL.config.DEFAULT_THEME_TRANSITION,background_transition:SL.config.DEFAULT_THEME_BACKGROUND_TRANSITION}},context:this}).done(function(t){var e=new SL.models.Theme(t);this.themeData.isEmpty()?(this.themeData.push(e),this.renderList(),this.makeDefaultTheme(e,null,!0)):(this.themeData.push(e),this.renderListItem(e,{prepend:!0,showDelay:3e3}),SL.view.parseTimes()),this.editTheme(e)}).fail(function(){SL.notify(SL.locale.get("THEME_CREATE_ERROR"),"negative")})},saveTheme:function(t,e,i){$.ajax({type:"PUT",url:SL.endpoints.THEMES_UPDATE(t.get("id")),data:{theme:t.toJSON()},context:this}).done(function(t){var i=this.renderListItem(new SL.models.Theme(t));SL.view.parseTimes(),t&&t.sanitize_messages&&t.sanitize_messages.length?SL.notify(t.sanitize_messages[0],"negative"):SL.notify(SL.locale.get("THEME_SAVE_SUCCESS")),SL.util.callback(e),setTimeout(function(){this.refreshListItemThumb(i)}.bind(this),2500),setTimeout(function(){this.refreshListItemThumb(i)}.bind(this),5e3)}).fail(function(){SL.notify(SL.locale.get("THEME_SAVE_ERROR"),"negative"),SL.util.callback(i)})},removeTheme:function(t,e,i){var n=this.getListItem(t);SL.prompt({anchor:i,title:SL.locale.get("THEME_REMOVE_CONFIRM"),type:"select",offsetX:15,data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Delete</h3>",selected:!0,className:"negative",callback:function(){var i=t.get("id");$.ajax({type:"DELETE",url:SL.endpoints.THEMES_DELETE(i),context:this}).done(function(){SL.util.anim.collapseListItem(n,function(){n.remove()}),SL.util.callback(e),this.themeData.removeByProperties({id:i}),this.panel&&this.panel.getTheme().get("id")===i&&this.panel.destroy(),SL.notify(SL.locale.get("THEME_REMOVE_SUCCESS"))}).fail(function(){SL.notify(SL.locale.get("THEME_REMOVE_ERROR"),"negative")})}.bind(this)}]})},makeDefaultTheme:function(t,e,i){$.ajax({type:"PUT",url:SL.endpoints.UPDATE_TEAM,data:{team:{default_theme_id:t.get("id")}},context:this}).done(function(){SL.current_team.set("default_theme_id",t.get("id")),this.updateListDefault(),i||SL.notify(SL.locale.get("THEME_DEFAULT_SAVE_SUCCESS")),SL.util.callback(e)}).fail(function(){i||SL.notify(SL.locale.get("THEME_DEFAULT_SAVE_ERROR"),"negative")})},unmakeDefaultTheme:function(t,e){$.ajax({type:"PUT",url:SL.endpoints.UPDATE_TEAM,data:{team:{default_theme_id:null}},context:this}).done(function(){SL.current_team.set("default_theme_id",null),this.updateListDefault(),e||SL.notify(SL.locale.get("THEME_DEFAULT_SAVE_SUCCESS")),SL.util.callback(t)}).fail(function(){e||SL.notify(SL.locale.get("THEME_DEFAULT_SAVE_ERROR"),"negative")})},getListItem:function(t){return this.listElement.find('[data-theme-id="'+(t?t.get("id"):null)+'"]')},refreshPreview:function(t,e){t=t||this.previewTheme,t||(t=new SL.models.Theme),"undefined"==typeof e&&(e=SL.current_team.get("global_css_output"));var i=this.getPreviewWindow();i&&t&&(i.SL&&i.SL.helpers&&i.SL.helpers.ThemeController.paint(t,{center:1===this.VERSION,globalCSS:e}),t.has("font_typekit")&&i.SL.fonts.loadTypekitFont(t.get("font_typekit")),t.has("font_google")&&i.SL.fonts.loadGoogleFont(t.get("font_google")),this.previewTheme=t)},reloadPreview:function(){var t=this.getPreviewWindow();t&&t.location.reload()},getPreviewWindow:function(){return this.previewFrame.length?this.previewFrame.get(0).contentWindow:null},onWindowBeforeUnload:function(){if(this.panel&&this.panel.hasUnsavedChanges())return SL.locale.get("LEAVE_UNSAVED_THEME")},onCreateThemeClicked:function(t){t.preventDefault(),this.createTheme()},onGlobalCSSClicked:function(){return this.panel?(this.panel.close(this.editTheme.bind(this,theme)),!1):($("html").addClass("is-editing-theme"),this.panel=new SL.views.themes.edit.GlobalCSSPanel(this,SL.current_team),this.panel.destroyed.add(function(){$("html").removeClass("is-editing-theme"),this.panel=null}.bind(this)),void this.bindLadda())}}),SL("views.themes.edit").Panel=Class.extend({DEFAULT_PAGE:"settings",PAGES:[{name:"Settings",id:"settings",factory:"renderSettings"},{name:"CSS",id:"css",factory:"renderCSS"},{name:"HTML",id:"html",factory:"renderHTML"},{name:"JS",id:"js",factory:"renderJS",condition:function(){return SL.current_team.get("allow_scripts")}},{name:"Palette",id:"palette",factory:"renderPalette",condition:function(){return this.editor.VERSION>1}},{name:"Snippets",id:"snippets",factory:"renderSnippets"}],init:function(t,e,i){this.editor=t,this.theme=e,this.themeOptionsConfig=i,this.previewTimeout=-1,this.destroyed=new signals.Signal,this.updatePreview=this.updatePreview.bind(this),this.paintPreview=this.paintPreview.bind(this),this.render(),this.load()},load:function(){this.theme.load().done(function(){this.theme=this.theme.clone(),this.afterLoad(),this.savedJSON=JSON.stringify(this.theme.toJSON()),this.checkUnsavedChanges()}.bind(this)).fail(function(){this.close(),SL.notify(SL.locale.get("GENERIC_ERROR"),"negative")}.bind(this))},afterLoad:function(){this.preloaderElement.addClass("hidden"),setTimeout(function(){this.preloaderElement.remove(),this.preloaderElement=null}.bind(this),500),this.renderHeader(),this.renderPages(),this.bind(),this.showPage(this.DEFAULT_PAGE),this.paintPreview()},render:function(){this.domElement=$('<div class="panel">'),this.domElement.appendTo(this.editor.editorInnerElement),this.pagesElement=$('<div class="pages">'),this.pagesElement.appendTo(this.domElement),this.preloaderElement=$('<div class="preloader"><div class="preloader-inner"><div class="preloader-spinner"></div></div></div>'),this.preloaderElement.appendTo(this.editor.editorInnerElement),SL.util.html.generateSpinners()},renderHeader:function(){this.headerElement=$('<header class="panel-header">').appendTo(this.domElement),this.cancelButton=$('<button class="button l grey cancel-button"><span class="icon i-chevron-left" style="font-size: 1.2em;"></span> Back</button>').appendTo(this.headerElement),this.saveButton=$('<button class="button l positive save-button ladda-button" data-style="zoom-out">Save</button>').appendTo(this.headerElement),this.saveButton.data("ladda",Ladda.create(this.saveButton.get(0))),this.onSaveClicked=this.onSaveClicked.bind(this),this.onCancelClicked=this.onCancelClicked.bind(this),this.saveButton.on("click",this.onSaveClicked),this.cancelButton.on("click",this.onCancelClicked),this.tabsElement=$('<div class="page-tabs">').appendTo(this.headerElement)},renderPages:function(){this.PAGES.forEach(function(t){("function"!=typeof t.condition||t.condition.call(this))&&($('<button class="page-tab" data-page-id="'+t.id+'">'+t.name+"</button>").on("click",this.showPage.bind(this,t.id)).appendTo(this.tabsElement),this[t.factory]())}.bind(this)),1===this.PAGES.length&&this.tabsElement.hide()},renderSettings:function(){this.settingsElement=$('<div class="page sl-form sl-scrollable" data-page-id="settings">').appendTo(this.pagesElement),this.settingsElement.append('<div class="unit name" data-required><label for="">Theme Name</label><input id="theme-name" type="text" value="'+(this.theme.get("name")||"Untitled")+'"></div>'),this.settingsElement.find("#theme-name").on("change",this.paintPreview),this.settingsElement.find("#theme-name").on("input",this.onNameInputChanged.bind(this)),this.renderThemeOptions()},renderThemeOptions:function(){var t=$.extend(this.themeOptionsConfig,{model:this.theme,container:this.settingsElement,themeEditor:!0,resolution:!0,supportsCustomFonts:!0});"no-color"!==t.colors[t.colors.length-1].id&&t.colors.push({id:"no-color",tooltip:"Specifies as few color styles as possible, useful if you want to write custom CSS from the ground up."}),"no-font"!==t.fonts[t.fonts.length-1].id&&t.fonts.push({id:"no-font",title:"None",tooltip:"Specifies as few typographic styles as possible, useful if you want to write custom CSS from the ground up."}),this.themeOptions=new SL.components.ThemeOptions(t),this.themeOptions.changed.add(this.paintPreview)},renderCSS:function(){this.css=new SL.views.themes.edit.pages.CSS(this,this.theme),this.css.appendTo(this.pagesElement),this.css.changed.add(this.checkUnsavedChanges.bind(this))},renderHTML:function(){this.html=new SL.views.themes.edit.pages.HTML(this,this.theme),this.html.appendTo(this.pagesElement),this.html.changed.add(this.checkUnsavedChanges.bind(this))},renderJS:function(){this.js=new SL.views.themes.edit.pages.JS(this,this.theme),this.js.appendTo(this.pagesElement),this.js.changed.add(this.checkUnsavedChanges.bind(this))},renderPalette:function(){this.palette=new SL.views.themes.edit.pages.Palette(this,this.theme),this.palette.appendTo(this.pagesElement),this.palette.changed.add(this.checkUnsavedChanges.bind(this))},renderSnippets:function(){this.snippets=new SL.views.themes.edit.pages.Snippets(this,this.theme),this.snippets.appendTo(this.pagesElement),this.snippets.changed.add(this.checkUnsavedChanges.bind(this))},bind:function(){this.onDocumentKeyDown=this.onDocumentKeyDown.bind(this),$(document).on("keydown",this.onDocumentKeyDown),this.domElement.on("click",".page-header .documentation-link",function(t){t.preventDefault();var e=$(t.currentTarget),i=e.closest(".page-header");i.toggleClass("expanded"),e.text(i.hasClass("expanded")?"Less info":"More info")}.bind(this))},showPage:function(t){this.domElement.find(".page").removeClass("past present future"),this.domElement.find('.page[data-page-id="'+t+'"]').addClass("present"),this.domElement.find('.page[data-page-id="'+t+'"]').prevAll().addClass("past"),this.domElement.find('.page[data-page-id="'+t+'"]').nextAll().addClass("future"),this.domElement.find(".panel-header .page-tab").removeClass("selected"),this.domElement.find('.panel-header .page-tab[data-page-id="'+t+'"]').addClass("selected"),"css"===t&&this.css?this.css.focus():"html"===t&&this.html?this.html.focus():"js"===t&&this.js?this.js.focus():"palette"===t&&this.palette&&this.palette.refresh(),setTimeout(function(){this.domElement.find(".page").addClass("transition")}.bind(this),1),this.resetScrollPosition()},resetScrollPosition:function(){this.domElement.scrollLeft(0).scrollTop(0),this.settingsElement&&this.settingsElement.scrollLeft(0).scrollTop(0)},updatePreview:function(t){"number"!=typeof t&&(t=250),clearTimeout(this.previewTimeout),this.previewTimeout=setTimeout(function(){this.paintPreview()}.bind(this),t)},paintPreview:function(){this.preprocess().then(function(){this.editor.refreshPreview(this.theme)}.bind(this),function(){this.editor.refreshPreview(this.theme)}.bind(this))},preprocess:function(t,e){this.theme.set("name",this.domElement.find("#theme-name").val());var i=[];return this.css&&i.push(this.css.persist()),this.html&&i.push(this.html.persist()),this.js&&i.push(this.js.persist()),this.checkUnsavedChanges(),Promise.all(i).then(t,e)},hasUnsavedChanges:function(){return this.theme&&this.savedJSON!==JSON.stringify(this.theme.toJSON())},checkUnsavedChanges:function(){this.domElement.toggleClass("has-unsaved-changes",this.hasUnsavedChanges())},save:function(t){var e=this.saveButton.data("ladda");e&&e.start(),this.preprocess().then(function(){this.editor.saveTheme(this.theme,function(){e&&e.stop(),this.savedJSON=JSON.stringify(this.theme.toJSON()),this.checkUnsavedChanges(),SL.util.callback(t)}.bind(this),function(){e&&e.stop()}.bind(this))}.bind(this),function(){SL.notify("Please fix all CSS errors before saving","negative"),e&&e.stop()}.bind(this))},close:function(t){this.hasUnsavedChanges()?SL.prompt({anchor:this.cancelButton,title:SL.locale.get("WARN_UNSAVED_CHANGES"),alignment:"b",type:"select",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Discard</h3>",className:"divider",callback:function(){this.destroy(),SL.util.callback(t)}.bind(this)},{html:"<h3>Save</h3>",className:"positive",selected:!0,callback:function(){SL.util.callback(t),this.save(this.destroy.bind(this))}.bind(this)}]}):(this.destroy(),SL.util.callback(t))},getTheme:function(){return this.theme},onNameInputChanged:function(){this.theme.set("name",this.domElement.find("#theme-name").val()),this.checkUnsavedChanges()},onSaveClicked:function(){this.save()},onCancelClicked:function(){this.close()},onDocumentKeyDown:function(t){(t.metaKey||t.ctrlKey)&&83===t.keyCode?(this.hasUnsavedChanges()&&this.save(),t.preventDefault()):27===t.keyCode&&this.close()},destroy:function(){this.isDestroyed||(this.isDestroyed=!0,clearTimeout(this.previewTimeout),this.destroyed.dispatch(),this.destroyed.dispose(),$(document).off("keydown",this.onDocumentKeyDown),this.css&&(this.css.destroy(),this.css=null),this.html&&(this.html.destroy(),this.html=null),this.js&&(this.js.destroy(),this.js=null),this.palette&&(this.palette.destroy(),this.palette=null),this.snippets&&(this.snippets.destroy(),this.snippets=null),this.themeOptions&&this.themeOptions.destroy(),this.preloaderElement&&this.preloaderElement.remove(),this.domElement&&this.domElement.remove())}}),SL("views.themes.edit").GlobalCSSPanel=SL.views.themes.edit.Panel.extend({PAGES:[{name:"Global CSS",id:"css",factory:"renderCSS"}],init:function(t,e){this.team=e,this.team.get("global_css_input")||this.team.set("global_css_input",""),this.team.get("global_css_output")||this.team.set("global_css_output",""),this.data={global_css_input:this.team.get("global_css_input"),global_css_output:this.team.get("global_css_output")},this._super(t),this.domElement.addClass("panel-global-css")},load:function(){this.afterLoad()},renderCSS:function(){this.css=new SL.views.themes.edit.pages.CSS(this,this.theme,{title:"Global CSS",description:"Add custom CSS or LESS styles to all decks created by your team. These styles are injected before any theme-specific CSS. ",setInput:function(t){this.data.global_css_input=t}.bind(this),getInput:function(){return this.data.global_css_input}.bind(this),setOutput:function(t){this.data.global_css_output=t}.bind(this),getOutput:function(){return this.data.global_css_output}.bind(this)}),this.css.appendTo(this.pagesElement),this.css.changed.add(this.checkUnsavedChanges.bind(this))},paintPreview:function(){this.preprocess().then(function(){this.editor.refreshPreview(this.theme,this.data.global_css_output)}.bind(this),function(){this.editor.refreshPreview(this.theme,this.data.global_css_output)}.bind(this))},preprocess:function(){return this.css.persist()},hasUnsavedChanges:function(){return this.team.get("global_css_input")!==this.data.global_css_input},save:function(t){var e=this.data.global_css_input,i=this.data.global_css_output,n=this.saveButton.data("ladda");n&&n.start(),this.preprocess().then(function(){$.ajax({url:SL.endpoints.UPDATE_TEAM,type:"PUT",data:{team:{global_css_input:e,global_css_output:i}},context:this}).done(function(){this.team.set("global_css_input",e),this.team.set("global_css_output",i),this.checkUnsavedChanges(),SL.util.callback(t)}).fail(function(){SL.notify("Failed to save, please try again","negative")}).always(function(){n&&n.stop()})}.bind(this),function(){SL.notify("Please fix all CSS errors before saving","negative"),n&&n.stop()}.bind(this))}}),SL("views.themes.edit.pages").CSS=Class.extend({init:function(t,e,i){this.config=$.extend({customClasses:!0,title:"CSS",description:"Specify custom styles using LESS or standard CSS. All selectors are automatically prefixed with .reveal when saved.",setInput:function(t){this.theme.set("less",t)}.bind(this),getInput:function(){return this.theme.get("less")}.bind(this),setOutput:function(t){this.theme.set("css",t)}.bind(this),getOutput:function(){return this.theme.get("css")}.bind(this)},i),this.panel=t,this.theme=e,this.changed=new signals.Signal,this.render(),this.bind()},render:function(){this.domElement=$('<div class="page" data-page-id="css">'),this.domElement.html(['<div class="page-header page-header-absolute">',"<h4>"+this.config.title+"</h4>","<p>"+this.config.description+"</p>",'<div class="header-buttons">','<button class="button light-grey documentation-link">More info</button>','<button class="button light-grey float-right insert-image hide-from-global-css" data-tooltip="Insert image URL"><span class="icon i-picture"></span></button>','<button class="button light-grey float-right custom-fonts hide-from-global-css" data-tooltip="Load custom fonts"><span class="icon i-type"></span></button>',"</div>",'<div class="documentation">',$("#css-panel-documentation").html(),"</div>","</div>",'<div class="editor-wrapper">','<div class="editor"></div>','<div class="error"></div>','<div class="info positive" data-tooltip="" data-tooltip-maxwidth="300" data-tooltip-align="left"><span class="icon i-info"></span></div>',"</div>"].join("")),this.insertImageButton=this.domElement.find(".insert-image"),this.customFontsButton=this.domElement.find(".custom-fonts"),this.editorElement=this.domElement.find(".editor"),this.errorElement=this.domElement.find(".error"),this.domElement.find(".info").hide()},setupCodeEditor:function(){if(!this.codeEditor){try{this.codeEditor=SL.util.createCodeEditor(this.editorElement.get(0),{mode:"text/x-less"})}catch(t){console.log("An error occurred while initializing the code editor.")}this.codeEditor.on("change",this.onInputChanged.bind(this)),this.codeEditor.setValue(this.config.getInput()||""),this.sync()}},bind:function(){this.insertImageButton.on("click",this.onInsertImageClicked.bind(this)),this.customFontsButton.on("click",this.onCustomFontsClicked.bind(this))},appendTo:function(t){this.domElement.appendTo(t),this.setupCodeEditor()},focus:function(){this.codeEditor.focus()},sync:function(){var t=SL.util.string.getCustomClassesFromLESS(this.codeEditor.getValue());if(t.length&&this.config.customClasses){var e="Found custom slide classes:<br>- "+t.join("<br>- ");this.domElement.find(".info").attr("data-tooltip",e).show()}else this.domElement.find(".info").attr("data-tooltip","").hide()},preprocess:function(){return new Promise(function(t,e){var i=this.getValue();i?less.render(".reveal { "+i+" }").then(function(e){this.errorElement.removeClass("visible");try{e=e.css}catch(t){console.log(t)}if(e){var n="";e=e.replace(/@import url\(["'\s]*(http:|https:)?\/\/(.*)\);?/gi,function(t){return n+=t+"\n",""}),e=n+e,this.config.setInput(i),this.config.setOutput(e),t()}}.bind(this),function(t){this.errorElement.addClass("visible"),this.errorElement.html((t.line?'<span class="line">Line '+t.line+": </span>":"")+t.message),e(t),this.changed&&this.changed.dispatch()}.bind(this)):(this.config.setInput(""),this.config.setOutput(""),t())}.bind(this))},persist:function(){return this.preprocess()},getValue:function(){return this.codeEditor?this.codeEditor.getValue():""},destroy:function(){this.changed&&(this.changed.dispose(),this.changed=null),this.codeEditor=null,this.panel=null,this.theme=null},onInputChanged:function(){this.sync(),this.panel.updatePreview()},onInsertImageClicked:function(){var t=SL.popup.open(SL.components.medialibrary.MediaLibrary,{select:SL.models.Media.IMAGE});t.selected.addOnce(function(t){t.isUploaded()?(this.codeEditor.replaceSelection(t.get("url")),this.focus()):t.uploadCompleted.add(function(){this.codeEditor.replaceSelection(t.get("url"))}.bind(this))}.bind(this))},onCustomFontsClicked:function(){var t=SL.popup.openOne(SL.components.popup.CustomFonts,{theme:this.theme});t.closed.addOnce(function(){this.panel.updatePreview(),this.changed.dispatch()}.bind(this))}}),SL("views.themes.edit.pages").HTML=Class.extend({init:function(t,e){this.panel=t,this.theme=e,this.changed=new signals.Signal,this.render(),this.bind()},render:function(){this.domElement=$('<div class="page" data-page-id="html">'),this.domElement.html(['<div class="page-header page-header-absolute">',"<h4>HTML</h4>","<p>Markup is inserted outside of individual slides. This is great for things like a company logo which is fixed on top of the presentation.</p>",'<div class="header-buttons">','<button class="button light-grey documentation-link">More info</button>','<button class="button light-grey float-right insert-image" data-tooltip="Insert image URL"><span class="icon i-picture"></span></button>',"</div>",'<div class="documentation">',$("#html-panel-documentation").html(),"</div>","</div>",'<div class="editor-wrapper">','<div class="editor"></div>',"</div>"].join("")),this.insertImageButton=this.domElement.find(".insert-image"),this.editorElement=this.domElement.find(".editor")},setupCodeEditor:function(){if(!this.codeEditor){try{this.codeEditor=SL.util.createCodeEditor(this.editorElement.get(0),{mode:"text/html"})}catch(t){console.log("An error occurred while initializing the code editor.")}this.codeEditor.on("change",this.onInputChanged.bind(this)),this.codeEditor.setValue(this.theme.get("html")||"")}},bind:function(){this.insertImageButton.on("click",this.onInsertImageClicked.bind(this))},appendTo:function(t){this.domElement.appendTo(t),this.setupCodeEditor()},focus:function(){this.codeEditor.focus()},persist:function(){return this.theme.set("html",this.getValue()),Promise.resolve()},getValue:function(){return this.codeEditor?this.codeEditor.getValue():""},destroy:function(){this.changed.dispose(),this.codeEditor=null,this.panel=null,this.theme=null},onInputChanged:function(){this.panel.updatePreview()},onInsertImageClicked:function(){var t=SL.popup.open(SL.components.medialibrary.MediaLibrary,{select:SL.models.Media.IMAGE});t.selected.addOnce(function(t){t.isUploaded()?(this.codeEditor.replaceSelection(t.get("url")),this.focus()):t.uploadCompleted.add(function(){this.codeEditor.replaceSelection(t.get("url"))}.bind(this))}.bind(this))}}),SL("views.themes.edit.pages").JS=Class.extend({init:function(t,e){this.panel=t,this.theme=e,this.changed=new signals.Signal,this.render(),this.bind()},render:function(){this.domElement=$('<div class="page" data-page-id="js">'),this.domElement.html(['<div class="page-header page-header-absolute">',"<h4>JavaScript</h4>","<p>Scripts will be executed when a deck that uses this theme is loaded. They are injected at the end of the document, after all other scripts.</p>",'<div class="header-buttons">','<button class="button light-grey float-right insert-image" data-tooltip="Insert image URL"><span class="icon i-picture"></span></button>',"</div>","</div>",'<div class="editor-wrapper">','<div class="editor"></div>',"</div>"].join("")),this.insertImageButton=this.domElement.find(".insert-image"),this.editorElement=this.domElement.find(".editor")},setupCodeEditor:function(){if(!this.codeEditor){try{this.codeEditor=SL.util.createCodeEditor(this.editorElement.get(0),{mode:"text/javascript"})}catch(t){console.log("An error occurred while initializing the code editor.")}this.codeEditor.on("change",this.onInputChanged.bind(this)),this.codeEditor.setValue(this.theme.get("js")||"")}},bind:function(){this.insertImageButton.on("click",this.onInsertImageClicked.bind(this))},appendTo:function(t){this.domElement.appendTo(t),this.setupCodeEditor()},focus:function(){this.codeEditor.focus()},persist:function(){return this.theme.set("js",this.getValue()),Promise.resolve()},getValue:function(){return this.codeEditor?this.codeEditor.getValue():""},destroy:function(){this.changed.dispose(),this.codeEditor=null,this.panel=null,this.theme=null},onInputChanged:function(){this.panel.updatePreview(1e3)},onInsertImageClicked:function(){var t=SL.popup.open(SL.components.medialibrary.MediaLibrary,{select:SL.models.Media.IMAGE});t.selected.addOnce(function(t){t.isUploaded()?(this.codeEditor.replaceSelection(t.get("url")),this.focus()):t.uploadCompleted.add(function(){this.codeEditor.replaceSelection(t.get("url"))}.bind(this))}.bind(this))}}),SL("views.themes.edit.pages").Palette=Class.extend({init:function(t,e){this.panel=t,this.theme=e,this.changed=new signals.Signal,this.onDocumentMouseUp=this.onDocumentMouseUp.bind(this),this.onDocumentMouseMove=this.onDocumentMouseMove.bind(this),this.onSaveButtonClicked=this.onSaveButtonClicked.bind(this),this.onListItemDelete=this.onListItemDelete.bind(this),this.onListItemMouseDown=this.onListItemMouseDown.bind(this),this.render(),this.bind()},render:function(){this.domElement=$('<div class="page" data-page-id="palette">'),this.domElement.html(['<div class="page-header">',"<h4>Color Palette</h4>","<p>Replace the default color options that we offer throughout the deck editor with your own custom color palette.</p>",'<div class="header-buttons">','<button class="button light-grey documentation-link">More info</button>',"</div>",'<div class="documentation">',$("#palette-panel-documentation").html(),"</div>","</div>",'<div class="page-body">','<div class="palette-picker">','<div class="palette-picker-api"></div>',"</div>",'<ul class="palette-list"></ul>',"</div>"].join("")),this.innerElement=this.domElement.find(".page-body"),this.pickerElement=this.domElement.find(".palette-picker"),this.pickerAPIElement=this.domElement.find(".palette-picker-api"),this.listElement=this.domElement.find(".palette-list"),this.renderPicker(),this.renderList(),this.checkIfEmpty()},renderPicker:function(){this.pickerAPIElement.spectrum({flat:!0,showInput:!0,showButtons:!1,showInitial:!1,showPalette:!1,showSelectionPalette:!1,preferredFormat:"hex",className:"palette-picker-spectrum",move:function(t){this.setPreviewColor(t.toHexString())}.bind(this),change:function(t){this.setPreviewColor(t.toHexString())}.bind(this)}),this.domElement.find(".palette-picker-spectrum .sp-input-container").append('<div class="palette-picker-save-button"><span class="icon i-plus"></span>Save color</div>'),this.pickerSaveButton=this.domElement.find(".palette-picker-save-button")},renderList:function(){this.listElement.empty(),this.theme.get("palette").forEach(this.renderListItem.bind(this))},renderListItem:function(t){var e=$('<li class="palette-list-item sl-form">');return e.data("color",t),e.html(['<div class="palette-list-item-color"></div>','<div class="palette-list-item-label">'+t+"</div>",'<div class="palette-list-item-delete"><span class="icon i-trash"></span></div>'].join("")),e.appendTo(this.listElement),e.toggleClass("is-light",tinycolor(t).isLight()),e.find(".palette-list-item-color").css("background-color",t),e.find(".palette-list-item-delete").on("click",this.onListItemDelete),e.on("mousedown",this.onListItemMouseDown),e},bind:function(){this.pickerSaveButton.on("click",this.onSaveButtonClicked.bind(this))},appendTo:function(t){this.domElement.appendTo(t)},setPreviewColor:function(t){this.pickerSaveButton.css({color:tinycolor(t).isLight()?"#222222":"#ffffff",backgroundColor:t})},checkIfEmpty:function(){0===this.listElement.find(".palette-list-item").length?this.listElement.append('<span class="palette-list-empty">No custom colors have been added to the palette. Click "Save color" to add one now.</span>'):this.listElement.find(".palette-list-empty").remove()},refresh:function(){this.pickerAPIElement.spectrum("set","#000000"),this.pickerAPIElement.spectrum("reflow"),this.setPreviewColor("#000000")},persist:function(){var t=this.listElement.find(".palette-list-item:not(.element)").map(function(){return $(this).data("color")}).toArray();this.theme.set("palette",t),this.checkIfEmpty(),this.changed.dispatch()},destroy:function(){this.changed.dispose(),this.listElement.find(".palette-list-item").off(),this.panel=null,this.theme=null},onSaveButtonClicked:function(){var t=this.renderListItem(this.pickerAPIElement.spectrum("get"));this.listElement.prepend(t),this.persist()},onListItemDelete:function(t){var e=$(t.target).closest(".palette-list-item");e.length?(e.remove(),this.persist()):SL.notify("An error occured while deleting this color")},onListItemMouseDown:function(t){var e=$(t.currentTarget);e.length&&e.is(".palette-list-item")&&0===$(t.target).closest(".palette-list-item-delete").length&&(this.dragTarget=e,this.dragGhost=e.clone().appendTo(this.listElement),this.dragGhost.addClass("drag-ghost"),this.dragTarget.addClass("drag-target"),this.dragOffsetX=t.clientX-this.dragTarget.offset().left,this.dragOffsetY=t.clientY-this.dragTarget.offset().top,this.listOffsetX=this.listElement.offset().left,this.listOffsetY=this.listElement.offset().top,this.listWidth=this.listElement.width(),this.listHeight=this.listElement.height(),this.listItemSize=this.dragTarget.outerHeight(),this.listItemCols=Math.floor(this.listWidth/this.listItemSize),$(document).on("mousemove",this.onDocumentMouseMove),$(document).on("mouseup",this.onDocumentMouseUp),this.onDocumentMouseMove(t))},onDocumentMouseMove:function(t){t.preventDefault();var e=this.listElement.find(".palette-list-item"),i=t.clientX-this.listOffsetX-this.dragOffsetX,n=t.clientY-this.listOffsetY-this.dragOffsetY;i=Math.max(Math.min(i,this.listWidth-this.listItemSize),0),n=Math.max(Math.min(n,this.listHeight-this.listItemSize),0),this.dragGhost.css({left:i,top:n});var s=Math.round(i/this.listItemSize),o=Math.round(n/this.listItemSize);s=Math.max(Math.min(s,this.listItemCols),0),o=Math.max(Math.min(o,e.length),0);var a=o*this.listItemCols+s,r=$(e[a]);r.is(this.dragTarget)||(this.dragTarget.index()>a?r.before(this.dragTarget):r.after(this.dragTarget))},onDocumentMouseUp:function(){this.dragTarget.removeClass("drag-target"),this.dragGhost.remove(),$(document).off("mousemove",this.onDocumentMouseMove),$(document).off("mouseup",this.onDocumentMouseUp),this.persist()}}),SL("views.themes.edit.pages").Snippets=Class.extend({init:function(t,e){this.panel=t,this.theme=e,this.changed=new signals.Signal,this.render(),this.bind(),this.syncMoveButtons()},render:function(){this.domElement=$('<div class="page" data-page-id="snippets">'),this.domElement.html(['<div class="page-header">',"<h4>Snippets</h4>","<p>Snippets are small HTML templates that your team members can use as building blocks when creating decks. These templates can contain placeholder variables that are filled out at the time of insertion.</p>",'<div class="header-buttons">','<button class="button light-grey documentation-link">More info</button>',"</div>",'<div class="documentation">',$("#snippet-panel-documentation").html(),"</div>","</div>",'<div class="page-body">','<ul class="snippet-list"></ul>','<ul class="snippet-controls snippet-list-item sl-form">','<div class="add-button-wrapper">','<button class="button l add-button">Add Snippet <span class="icon i-plus"></span></button>',"</div>",'<div class="unit text">',"<label>Title</label>",'<input class="title-value" maxlength="200" type="text" readonly>',"</div>",'<div class="unit text">',"<label>Template</label>",'<textarea class="template-value" rows="4" readonly></textarea>',"</div>","</ul>","</div>"].join("")),this.innerElement=this.domElement.find(".page-body"),this.listElement=this.domElement.find(".snippet-list"),this.controlsElement=this.domElement.find(".snippet-controls"),this.addButton=this.domElement.find(".snippet-controls .add-button-wrapper"),this.renderList()},renderList:function(){this.listElement.empty(),this.theme.get("snippets").forEach(this.renderListItem.bind(this))},renderListItem:function(t){var e=$('<li class="snippet-list-item sl-form">');return e.html(['<div class="unit text">',"<label>Title</label>",'<input class="title-value" maxlength="200" value="'+t.get("title")+'" type="text" spellcheck="false">',"</div>",'<div class="unit text">',"<label>Template</label>",'<textarea class="template-value" rows="4" spellcheck="false">'+t.get("template")+"</textarea>",'<div class="snippet-status" data-tooltip="" data-tooltip-maxwidth="400" data-tooltip-align="left"><span class="icon i-info"></span></div>',"</div>",'<div class="snippet-list-item-footer">','<button class="button light-grey delete-button" data-tooltip="Delete" data-tooltip-delay="1000"><snap class="icon i-trash"></snap></button>','<button class="button light-grey preview-button" data-tooltip="Preview" data-tooltip-delay="1000"><snap class="icon i-eye"></snap></button>','<button class="button light-grey move-up-button" data-tooltip="Move Up" data-tooltip-delay="1000"><snap class="icon i-chevron-up"></snap></button>','<button class="button light-grey move-down-button" data-tooltip="Move Down" data-tooltip-delay="1000"><snap class="icon i-chevron-down"></snap></button>',"</div>"].join("")),e.appendTo(this.listElement),e.data("model",t),e.find("input, textarea").on("input",this.onSnippetChange.bind(this)),e.find("input, textarea").on("focus",this.onSnippetFocused.bind(this)),e.find(".delete-button").on("click",this.onSnippetDelete.bind(this)),e.find(".preview-button").on("click",this.onSnippetFocused.bind(this)),e.find(".move-up-button").on("click",this.onSnippetMoveUp.bind(this)),
e.find(".move-down-button").on("click",this.onSnippetMoveDown.bind(this)),this.validateSnippet(e),e},bind:function(){this.addButton.on("click",this.addSnippet.bind(this))},appendTo:function(t){this.domElement.appendTo(t),this.listElement.find(".snippet-list-item").each(function(t,e){this.layoutSnippet($(e))}.bind(this))},addSnippet:function(){this.theme.get("snippets").create({title:"New snippet"}).then(function(t){var e=this.renderListItem(t);e.data("model",t),e.find(".title-value").val(t.get("title")),e.find("input").first().focus().select(),setTimeout(function(){var t=this.domElement.prop("scrollHeight");t-=this.domElement.outerHeight(!0),t-=this.controlsElement.outerHeight(!0),this.domElement.scrollTop(t)}.bind(this),1),this.changed.dispatch(),this.syncMoveButtons()}.bind(this))},layoutSnippet:function(t){var e=t.find(".template-value");e.attr("rows",4);var i=parseFloat(e.css("line-height")),n=e.prop("scrollHeight"),s=e.prop("clientHeight");n>s&&e.attr("rows",Math.min(Math.ceil(n/i),10))},validateSnippet:function(t){var e=t.data("model"),i=[],n=[],s=e.templateHasVariables(),o=e.templateHasSelection();if(s&&o)n.push("Templates can not mix variables and selection tags.");else if(s){var a=e.getTemplateVariables();i.push("Found "+a.length+" variables:"),a.forEach(function(t){t.defaultValue?i.push("- "+t.label+" (default: "+t.defaultValue+")"):i.push("- "+t.label)})}n.length?t.find(".snippet-status").addClass("negative").show().attr("data-tooltip",n.join("<br>")):i.length?t.find(".snippet-status").removeClass("negative").show().attr("data-tooltip",i.join("<br>")):t.find(".snippet-status").removeClass("negative").hide()},previewSnippet:function(t){var e=this.panel.editor.getPreviewWindow(),i=e.$("#snippet-slide");0===i.length&&(i=$('<section id="snippet-slide">').appendTo(e.$(".reveal .slides"))),i.html(['<div class="sl-block" data-block-type="html" style="width: 100%; left: 0; top: 0; height: auto;">','<div class="sl-block-content">',t.templatize(t.getTemplateVariables()),"</div>","</div>"].join("")),e.SL.util.skipCSSTransitions(),e.Reveal.sync(),e.Reveal.slide(i.index())},syncSnippetOrder:function(){var t=this.listElement.find(".snippet-list-item"),e=this.theme.get("snippets");t.sort(function(t,i){var n=e.find($(t).data("model")),s=e.find($(i).data("model"));return n-s}.bind(this)),t.each(function(t,e){this.listElement.append(e)}.bind(this)),this.syncMoveButtons()},syncMoveButtons:function(){this.listElement.find(".snippet-list-item").each(function(t,e){e=$(e),e.find(".move-up-button").css("display",e.is(":first-child")?"none":""),e.find(".move-down-button").css("display",e.is(":last-child")?"none":"")})},destroy:function(){this.changed.dispose(),this.listElement.find(".snippet-list-item").off().removeData("model");var t=this.panel.editor.getPreviewWindow();t.$("#snippet-slide").remove(),t.Reveal.sync(),t.Reveal.slide(0),this.panel=null,this.theme=null},onSnippetFocused:function(t){var e=$(t.target).closest(".snippet-list-item");e.length&&this.previewSnippet(e.data("model"))},onSnippetChange:function(t){var e=$(t.target).closest(".snippet-list-item");if(e.length){var i=e.find(".title-value").val(),n=e.find(".template-value").val(),s=SL.util.html.findScriptTags(n);if(s.length>0)return SL.notify("Scripts are not allowed. Please remove all script tags for this snippet to save.","negative"),!1;var o=e.data("model");o.set("title",i),o.set("template",n),this.layoutSnippet(e),this.validateSnippet(e),this.previewSnippet(o),this.changed.dispatch()}},onSnippetDelete:function(t){var e=$(t.target).closest(".snippet-list-item");if(e.length){var i=e.data("model");i?SL.prompt({anchor:$(t.currentTarget),title:SL.locale.get("THEME_SNIPPET_DELETE_CONFIRM"),type:"select",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Remove</h3>",selected:!0,className:"negative",callback:function(){SL.util.anim.collapseListItem(e,function(){e.remove(),this.syncMoveButtons()}.bind(this));var t=this.theme.get("snippets");t.remove(e.data("model")),this.changed.dispatch()}.bind(this)}]}):SL.notify("An error occured while deleting this snippet")}else SL.notify("An error occured while deleting this snippet")},onSnippetMoveUp:function(t){var e=$(t.target).closest(".snippet-list-item");if(e.length){var i=e.data("model");if(i){var n=this.theme.get("snippets");n.shiftLeft(n.find(i)),this.changed.dispatch(),this.syncSnippetOrder()}}},onSnippetMoveDown:function(t){var e=$(t.target).closest(".snippet-list-item");if(e.length){var i=e.data("model");if(i){var n=this.theme.get("snippets");n.shiftRight(n.find(i)),this.changed.dispatch(),this.syncSnippetOrder()}}}}),SL("views.themes").Preview=SL.views.Base.extend({init:function(){this._super(),SL.util.setupReveal({openLinksInTabs:!0}),window.parent!==window.self&&window.parent.postMessage({type:"theme-preview-ready"},window.location.origin)}}),SL("views.users").ShowDeckFilters=Class.extend({init:function(t,e){this.parentView=t,this.tags=e,this.domElement=$(".deck-filters"),this.wrapperElement=$(".deck-filters-wrapper"),this.userInfoElement=$(".user-info"),this.bind(),this.setupTabs(),this.setupTags(),this.setupFilters(),this.tagChanged=new signals.Signal,this.tagRenamed=new signals.Signal,this.tabChanged=new signals.Signal,this.restoreFilters(),this.layout()},bind:function(){$(window).on("scroll",$.throttle(this.onWindowScroll.bind(this),30)),$(window).on("resize",$.throttle(this.onWindowResize.bind(this),30))},layout:function(t){var e=$(window).scrollTop(),i=e>this.userInfoElement.offset().top+this.userInfoElement.outerHeight(!0),n=this.parentView.isSmallScreen(),s=this.isFixed;this.isFixed=i&&!n,this.isFixed==s&&"resize"!==t||(this.isFixed?(this.wrapperElement.addClass("fixed"),this.wrapperElement.css("height",this.domElement.outerHeight()),this.domElement.css("width",$(".column").width())):(this.domElement.css("width",""),this.wrapperElement.css("height",""),this.wrapperElement.removeClass("fixed")))},scrollToFirstDeck:function(){var t=$(window).scrollTop(),e=this.userInfoElement.offset().top+this.userInfoElement.outerHeight(!0);t>e&&$(window).scrollTop(e)},setupTabs:function(){this.domElement.find(".deck-filters-tabs").length&&(this.defaultTabID=this.domElement.find(".deck-filters-tab.selected").first().attr("data-tab-id"),this.selectedTab=this.defaultTabID,this.domElement.find(".deck-filters-tags").toggleClass("hidden",this.defaultTabID!==SL.views.users.ShowDeckFilters.PERSONAL_TAB),this.domElement.find(".deck-filters-tabs").on("vclick",".deck-filters-tab",function(t){this.selectTab($(t.currentTarget).attr("data-tab-id"))}.bind(this)))},setupFilters:function(){this.onSortOptionSelected=this.onSortOptionSelected.bind(this),this.sortDecks=this.sortDecks.bind(this),this.searchDecks=$.throttle(this.searchDecks.bind(this),300),this.saveFilters=$.throttle(this.saveFilters.bind(this),100),this.setupSortOptions(),this.domElement.find(".deck-filters-sort").on("vclick",function(t){return this.sortOptions.forEach(function(t){t.selected=t.value===this.sortValue}.bind(this)),SL.prompt({anchor:$(t.currentTarget),title:"Sort decks",type:"list",alignment:"b",data:this.sortOptions,optional:!0,cancelButton:!1}),!1}.bind(this)),this.domElement.find(".deck-filters-search, .deck-filters-search-icon").on("vclick",function(t){this.domElement.find(".deck-filters-search").focus(),t.preventDefault(),SL.analytics.track("User.show: Search")}.bind(this)),this.domElement.find(".deck-filters-search").on("input",function(t){this.searchDecks($(t.currentTarget).val())}.bind(this)),this.domElement.find(".deck-filters-search-clear").on("vclick",function(t){this.searchDecks(""),this.domElement.find(".deck-filters-search").val(""),t.preventDefault()}.bind(this))},setupSortOptions:function(){this.sortOptions=[],this.sortOptions.push({value:"created",title:"Newest first",callback:this.onSortOptionSelected,method:function(t,e){return moment($(e).data("model").get("created_at")).unix()-moment($(t).data("model").get("created_at")).unix()}.bind(this)}),this.sortOptions.push({value:"created-reverse",title:"Oldest first",callback:this.onSortOptionSelected,method:function(t,e){return moment($(t).data("model").get("created_at")).unix()-moment($(e).data("model").get("created_at")).unix()}.bind(this)}),this.domElement.find('.deck[data-visibility="all"]').length&&this.sortOptions.push({value:"views",title:"Most views",callback:this.onSortOptionSelected,method:function(t,e){var i=$(t).data("model"),n=$(e).data("model"),s=i.get("visibility")===SL.models.Deck.VISIBILITY_ALL?i.get("view_count"):-1,o=n.get("visibility")===SL.models.Deck.VISIBILITY_ALL?n.get("view_count"):-1;return o-s}.bind(this)}),this.sortOptions.push({value:"az",title:"Alphabetically",callback:this.onSortOptionSelected,method:function(t,e){return t=$(t).data("model").get("title").trim().toLowerCase(),e=$(e).data("model").get("title").trim().toLowerCase(),t<e?-1:t>e?1:0}.bind(this)}),this.sortValueDefault=this.sortOptions[0].value,this.sortValue=this.sortValueDefault},setupTags:function(){this.tags.changed.add(this.onTagCollectionChanged.bind(this)),this.tags.associationChanged.add(this.onTagAssociationChanged.bind(this)),this.tags.forEach(this.renderTag.bind(this)),this.tagStar=$('<span class="star icon i-star" data-tooltip="This the default tag"></span>'),this.tagStar.on("vclick",function(t){this.showTagSettings($(t.target).closest(".deck-filters-tag")),t.stopImmediatePropagation(),t.preventDefault()}.bind(this)),this.refreshTags(),this.domElement.find(".deck-filters-tags").on("vclick",".deck-filters-tag .settings-button",function(t){this.showTagSettings($(t.target).closest(".deck-filters-tag"),t.currentTarget),t.stopImmediatePropagation(),t.preventDefault()}.bind(this)),this.domElement.find(".deck-filters-tags").on("vclick",".deck-filters-tag:not(.editing)",function(t){$(t.currentTarget).is(".deck-filters-tags-all")?(this.clearTagFilter(),this.scrollToFirstDeck()):this.selectTag($(t.currentTarget).data("tag"))}.bind(this)),this.afterTagsChanged();var t=this.domElement.find(".deck-filters-tags-new");t.length&&(t.on("vclick",this.createTag.bind(this)),SL.util.skipCSSTransitions(t))},showTagSettings:function(t,e){var i=[{label:"Rename",icon:"pen-alt2",callback:this.startEditingTag.bind(this,t)},{label:"Set as default",icon:"star",callback:this.setDefaultTag.bind(this,t)},{label:"Delete",icon:"trash",callback:this.deleteTag.bind(this,t)}];SL.current_user.settings.get("default_deck_tag_id")===t.data("tag").get("id")&&(i[1].className="active",i[1].label="Clear default",i[1].callback=this.clearDefaultTag.bind(this,t));var n=new SL.components.Menu({anchor:e||t,anchorSpacing:15,destroyOnHide:!0,options:i});n.show()},renderTag:function(t){var e=$(['<div class="deck-filters-tag focus-outline" tabindex="0">','<span class="name"></span>','<span class="deck-filters-match-count"></span>',"</div>"].join(""));return this.parentView.isOwner()&&e.append('<span class="settings-button icon i-cog"></span>'),e.data("tag",t),e.attr("data-tag-id",t.get("id")),e.find(".name").text(t.get("name")),e.appendTo(this.domElement.find(".deck-filters-tags-list")),e},createTag:function(){this.tags.create().then(function(t){var e=this.renderTag(t).addClass("intro is-new");this.refreshTags({sort:!1}),this.startEditingTag(e),this.afterTagsChanged()}.bind(this),function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative")}.bind(this))},startEditingTag:function(t){t.addClass("editing");var e=t.data("tag"),i=t.find(".name").hide(),n=function(){s.css("width",i.text(s.val()).width()+6)},s=$('<input type="text" class="name-input" spellcheck="false" />').val(e.get("name")).prependTo(t).on("blur",this.stopEditingTag.bind(this,t)).on("input",n).on("keydown",function(i){13===i.keyCode?this.stopEditingTag(t):27===i.keyCode&&(s.val(e.get("name")),this.stopEditingTag(t))}.bind(this)).focus().select();n()},stopEditingTag:function(t){t.removeClass("editing intro");var e=t.data("tag"),i=t.find(".name-input"),n=i.val().trim();n&&(e.set("name",n),e.save(["name"]).then(this.saveFilters.bind(this))),i.remove(),t.find(".name").text(e.get("name")).show(),this.refreshTags(),this.parentView.syncSelection(),this.tagRenamed.dispatch(),t.removeClass("is-new")},deleteTag:function(t){SL.prompt({anchor:t,title:SL.locale.get("TAG_DELETE_CONFIRM"),type:"select",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Delete</h3>",selected:!0,className:"negative",callback:function(){var e=t.data("tag");e.destroy().done(function(){t.hasClass("selected")&&this.clearTagFilter(),t.removeClass("selected"),SL.util.anim.collapseListItemHorizontal(t,function(){t.remove()}.bind(this)),this.tags.remove(e),this.afterTagsChanged(),SL.notify(SL.locale.get("TAG_DELETE_SUCCESS"))}.bind(this)).fail(function(){SL.notify(SL.locale.get("TAG_DELETE_ERROR"),"negative")}.bind(this))}.bind(this)}]})},setDefaultTag:function(t){SL.prompt({anchor:t,title:SL.locale.get("TAG_DEFAULT_CONFIRM"),type:"select",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Set default</h3>",selected:!0,className:"positive",callback:function(){var e=t.data("tag");SL.current_user.settings.set("default_deck_tag_id",e.get("id")),SL.current_user.settings.save(["default_deck_tag_id"]).then(function(){SL.notify("Updated default tag")},function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative")}),this.saveFilters(),this.refreshTags({sort:!1,count:!1})}.bind(this)}]})},clearDefaultTag:function(){SL.current_user.settings.set("default_deck_tag_id",null),SL.current_user.settings.save(["default_deck_tag_id"]).then(function(){SL.notify("Cleared default tag")},function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative")}),this.saveFilters(),this.refreshTags({sort:!1,count:!1})},selectTab:function(t){return 0!==this.domElement.find(".deck-filters-tabs").length&&(t!==SL.views.users.ShowDeckFilters.TRASH_TAB||this.hasLoadedTrash||(this.hasLoadedTrash=!0,this.parentView.reloadTrash().then(this.afterFiltersChanged.bind(this))),this.domElement.find(".deck-filters-tab").removeClass("selected"),this.domElement.find(".deck-filters-tab[data-tab-id="+t+"]").addClass("selected"),$(".decks").removeClass("visible"),$(".decks[data-tab-id="+t+"]").addClass("visible"),this.domElement.find(".deck-filters-tags").toggleClass("hidden",t!==SL.views.users.ShowDeckFilters.PERSONAL_TAB),this.selectedTab=t,this.afterFiltersChanged(),this.scrollToFirstDeck(),void this.tabChanged.dispatch())},selectTag:function(t){this.parentView.clearSelection(),this.domElement.find(".deck-filters-tag").removeClass("selected"),this.domElement.find(".deck-filters-tag[data-tag-id="+t.get("id")+"]").addClass("selected"),this.selectedTag=t,this.filterByTag(t),this.scrollToFirstDeck(),this.tagChanged.dispatch()},getSelectedTag:function(){return this.selectedTag},getDefaultTagID:function(){return SL.util.user.isLoggedIn()?SL.current_user.settings.get("default_deck_tag_id"):SLConfig.user&&SLConfig.user.settings&&"number"==typeof SLConfig.user.settings.default_deck_tag_id?SLConfig.user.settings.default_deck_tag_id:void 0},refreshTabs:function(t){if(this.domElement.find(".deck-filters-tab[data-tab-id]").each(function(e,i){i=$(i);var n=i.attr("data-tab-id"),s=$('.decks[data-tab-id="'+n+'"]'),o=s.find(">li").length;t instanceof Array&&t.indexOf(n)===-1||(i.find(".deck-filters-match-count").text(o),o>0&&i.removeClass("hidden"))}.bind(this)),this.domElement.find(".deck-filters-tab:not(.hidden)").length>1?(this.domElement.find(".deck-filters-tabs").removeClass("hidden"),this.domElement.find(".deck-filters-divider").removeClass("hidden")):(this.domElement.find(".deck-filters-tabs").addClass("hidden"),this.domElement.find(".deck-filters-divider").addClass("hidden")),this.domElement.find(".deck-filters-tab.selected.hidden").length){var e=this.domElement.find(".deck-filters-tab:not(.hidden)").first().attr("data-tab-id");e&&this.selectTab(e)}$(".decks:not(:has(*))").empty()},refreshTags:function(t){t=$.extend({sort:!0,count:!0},t);var e=this.domElement.find(".deck-filters-tags-list"),i=e.find(".deck-filters-tag").toArray();if(t.sort){var n=i.map(function(t){return $(t).data("tag").get("id")}).join(",");i.sort(function(t,e){return t=$(t).data("tag").get("name").toLowerCase(),e=$(e).data("tag").get("name").toLowerCase(),t<e?-1:t>e?1:0});var s=i.map(function(t){return $(t).data("tag").get("id")}).join(",");if(n!==s){this.parentView.flash(e);var o=e.find(".is-new");o.length&&(o.addClass("highlight-new"),setTimeout(function(){o.removeClass("highlight-new")},1500))}}t.count&&i.forEach(function(t){t=$(t),t.find(".deck-filters-match-count").text(t.data("tag").itemCount()),t.appendTo(e)});var a=this.getDefaultTagID();a?this.tagStar.insertAfter(e.find(".deck-filters-tag[data-tag-id="+a+"] .name")):this.tagStar.detach()},sortDecks:function(t){var e=this.getSortOptionByValue(t);e&&(this.sortValue=t,this.domElement.find(".deck-filters-sort").attr("data-tooltip","Sort: "+e.title),this.domElement.find(".deck-filters-sort").toggleClass("is-set",this.sortValue!==this.sortValueDefault),$(".decks").each(function(){var t=$(this).find(".deck");t.sort(e.method),t.detach().appendTo(this)}),this.afterFiltersChanged())},filterByTag:function(t){var e=$(".decks[data-tab-id="+SL.views.users.ShowDeckFilters.PERSONAL_TAB+"]");e.find(".deck").each(function(){$(this).toggleClass("hidden-via-tag",!t.hasItem($(this).data("model")))}),this.afterFiltersChanged(),this.parentView.loadImagesInView()},clearTagFilter:function(){this.selectedTag=null;var t=$(".decks[data-tab-id="+SL.views.users.ShowDeckFilters.PERSONAL_TAB+"]");this.domElement.find(".deck-filters-tag").removeClass("selected"),this.domElement.find(".deck-filters-tags-all").addClass("selected"),t.removeClass("no-results"),t.find(".deck").removeClass("hidden-via-tag"),this.afterFiltersChanged(),this.tagChanged.dispatch()},searchDecks:function(t){$(".decks").unhighlight(),t=(t||"").trim().toLowerCase(),""===t?$(".decks .deck").removeClass("hidden-via-search"):$(".decks .deck").each(function(e,i){i=$(i);var n=i.data("model");i.toggleClass("hidden-via-search",n.get("title").toLowerCase().indexOf(t)===-1&&n.get("description").toLowerCase().indexOf(t)===-1&&i.find(".deck-tag").text().toLowerCase().indexOf(t)===-1),t.length>1&&i.find(".deck-title-value, .deck-description-value, .deck-tag").highlight(t)}.bind(this)),this.searchValue=t,this.saveFilters(),this.afterFiltersChanged(!0),this.parentView.loadImagesInView()},saveFilters:function(){if(Modernizr.history){var t=[],e=SL.routes.USER(SLConfig.user.username);this.sortValue!==this.sortValueDefault&&t.push("sort="+encodeURIComponent(this.sortValue)),this.searchValue&&""!==this.searchValue&&t.push("search="+encodeURIComponent(this.searchValue));var i=this.selectedTab===SL.views.users.ShowDeckFilters.PERSONAL_TAB;i&&this.selectedTag&&this.selectedTag.has("slug")&&this.selectedTag.get("id")!==this.getDefaultTagID()?e=SL.routes.DECK_TAG(SLConfig.user.username,this.selectedTag.get("slug")):this.selectedTab&&""!==this.selectedTab&&this.selectedTab!==this.defaultTabID&&t.push("tab="+encodeURIComponent(this.selectedTab)),t.length?window.history.replaceState(null,null,e+"?"+t.join("&")):window.history.replaceState(null,null,e)}},restoreFilters:function(){var t=SL.util.getQuery();t.search&&(this.domElement.find(".deck-filters-search").val(t.search),this.searchDecks(t.search)),t.sort&&this.sortDecks(t.sort),t.tab&&this.selectTab(t.tab);var e=window.location.pathname.split("/").filter(function(t){return""!==t});if("decks"===e[1]&&3===e.length){var i=this.tags.getByProperties({slug:e.pop()});i&&this.selectTag(i)}else if(this.getDefaultTagID()){var i=this.tags.getByID(this.getDefaultTagID());i&&this.selectTag(i)}},refreshFilters:function(){this.searchValue&&this.searchDecks(this.searchValue),this.sortValue&&this.sortDecks(this.sortValue),this.selectedTag&&this.filterByTag(this.selectedTag)},afterFiltersChanged:function(t){var e=this.parentView.hasLoadedRemainingDecks();$(".decks:not(.loading) .deck-placeholder").remove(),$(".decks:not(.loading):not(:empty)").each(function(){if(0===$(this).find(".deck:not(.hidden-via-search):not(.hidden-via-tag)").length){var t=$('<div class="deck-placeholder"><p></p></div>');t.find("p").text(e?"There are no decks matching the current filters.":"Loading..."),t.appendTo(this)}}),this.saveFilters(),this.parentView.loadImagesInView(),t!==!0&&this.parentView.flashDecks(),e||this.parentView.loadRemainingDecks()},getSortOptionByValue:function(t){return this.sortOptions.filter(function(e){return e.value===t}).shift()},afterTagsChanged:function(){this.tags.isEmpty()?(this.domElement.find(".deck-filters-tags").addClass("empty"),this.domElement.find(".deck-filters-tags-new").removeAttr("data-tooltip")):(this.domElement.find(".deck-filters-tags").removeClass("empty"),this.domElement.find(".deck-filters-tags-new").attr("data-tooltip","Create tag"))},onSortOptionSelected:function(t){SL.analytics.track("User.show: Sort",t),this.sortDecks(t)},onTagCollectionChanged:function(){this.refreshTags(),this.selectedTag&&this.refreshFilters()},onTagAssociationChanged:function(t){this.refreshTags(),this.selectedTag==t&&this.refreshFilters()},onWindowScroll:function(){this.layout()},onWindowResize:function(){this.layout("resize")}}),SL.views.users.ShowDeckFilters.PERSONAL_TAB="personal",SL.views.users.ShowDeckFilters.SHARED_TAB="shared",SL.views.users.ShowDeckFilters.TRASH_TAB="trash",SL("views.users").Show=SL.views.Base.extend({init:function(){this._super(),SL.util.device.IS_PHONE&&$("html").addClass("is-mobile-phone"),$(".decks-outline").remove(),this.decksPagination={current:1,total:Math.ceil(window.SLTotalDecks/window.SLDecksPerPage),html:""},this.bind(),this.setupAnnouncement(),this.setupDecks(),this.renderToolbar(),this.tags=new SL.collections.DeckTags(window.SLDeckTags||{}),this.filters=new SL.views.users.ShowDeckFilters(this,this.tags),this.filters.tagChanged.add(this.clearSelection.bind(this)),this.filters.tabChanged.add(this.clearSelection.bind(this)),this.filters.tagChanged.add(this.refreshUntagButtons.bind(this)),this.filters.tagRenamed.add(this.refreshUntagButtons.bind(this)),this.filters.tagRenamed.add(this.syncDeckTags.bind(this)),this.tags.changed.add(this.onTagsChanged.bind(this)),this.tags.associationChanged.add(this.onTagAssociationChanged.bind(this)),$("section.presentations").removeClass("loading-filters"),this.loadImagesInView(),this.loadImagesInView=$.throttle(this.loadImagesInView,200),this.refreshUntagButtons(),this.syncDeckTags()},bind:function(){this.onDeckClicked=this.onDeckClicked.bind(this),this.onDeckMouseDown=this.onDeckMouseDown.bind(this),this.onDeckMouseMove=this.onDeckMouseMove.bind(this),this.onDeckMouseUp=this.onDeckMouseUp.bind(this),this.getDeckList(SL.views.users.ShowDeckFilters.PERSONAL_TAB).on("vclick",".deck-tag",function(t){t.preventDefault();var e=$(t.target).closest(".deck").data("model"),i=$(t.target).closest(".deck-tag").attr("data-tag-id"),n=this.tags.getByID(i);n&&($(t.target).closest(".deck-tag-remove").length>0?this.tags.removeTagFrom(n,[e]):this.filters.selectTag(n))}.bind(this)),$(document).on("keydown",this.onDocumentKeyDown.bind(this)),$(window).on("scroll",$.throttle(this.onWindowScroll.bind(this),100))},setupAnnouncement:function(){if(Modernizr.localstorage&&SL.current_user.isEnterpriseManager()&&SL.current_team&&SL.current_team.get("beta_new_editor")===!1){var t="slides-team-has-seen-new-editor-announcement";if(!localStorage.getItem(t)){var e=$(['<section class="announcement">',"<h3>New Editor</h3>",'<p>We have released a new and greatly improved presentation editor. Have a look at the <a href="http://slides.com/news/new-editor/" target="_blank">demo presentation</a> for a quick overview.</p>',"<p>To enable the new editor, please visit the team settings page.</p>",'<a class="button positive" href="/edit#beta-features">Team settings</a>','<a class="button grey dismiss-button">Dismiss</a>',"</section>"].join(""));e.find(".dismiss-button").on("click",function(){e.remove(),localStorage.setItem(t,"completed")}),$(".main section").first().before(e)}}},renderToolbar:function(){this.toolbar=$(".selection-toolbar"),this.toolbar.find(".trash-selection").on("vclick",this.trashSelection.bind(this)),this.toolbar.find(".clear-selection").on("vclick",this.clearSelection.bind(this)),this.toolbar.find(".tag-selection").on("vclick",this.tagSelection.bind(this))},setupDecks:function(){$(".decks .deck").each(function(t,e){e=$(e),e.data("initialized")!==!0&&(e.data("initialized",!0),e.data("model",new SL.models.Deck({user:{id:parseInt(e.attr("data-user-id"),10),username:e.attr("data-username"),account_type:e.attr("data-user-account-type")},id:parseInt(e.attr("data-id"),10),slug:e.attr("data-slug"),title:e.find(".deck-title-value").text(),description:e.find(".deck-description-value").text(),view_count:e.attr("data-view-count")||0,created_at:e.attr("data-created-at"),updated_at:e.attr("data-updated-at"),visibility:e.attr("data-visibility")})),e.find(".untag").on("vclick",this.onUntagClicked.bind(this,e)),e.find(".share").on("vclick",this.onShareClicked.bind(this,e)),e.find(".fork").on("vclick",this.onForkClicked.bind(this,e)),e.find(".clone").on("vclick",this.onCloneClicked.bind(this,e)),e.find(".trash").on("vclick",this.onTrashClicked.bind(this,e)),e.find(".recover").on("vclick",this.onRecoverClicked.bind(this,e)),e.find(".destroy").on("vclick",this.onDestroyClicked.bind(this,e)),e.find(".visibility").on("vclick",this.onVisibilityClicked.bind(this,e)),e.find(".deck-view").on("vclick",this.onDeckViewClicked.bind(this,e)),e.find(".selection-checkbox").on("vclick",this.onSelectionClicked.bind(this,e)),e.hasClass("is-owner")&&!e.hasClass("trash")&&(e.find(".deck-title-value").attr({"data-tooltip":"Click to edit","data-tooltip-alignment":"l","data-tooltip-delay":200}),e.find(".deck-title-value").on("click",this.onDeckTitleClicked.bind(this,e)),e.find(".deck-description-value").attr({"data-tooltip":"Click to edit","data-tooltip-alignment":"l","data-tooltip-delay":200}),e.find(".deck-description-value").on("click",this.onDeckDescriptionClicked.bind(this,e)),e.find(".deck-link, .deck-thumb").on("vclick",this.onDeckClicked),e.on("mousedown",this.onDeckMouseDown)),e.find(".ladda-button").each(function(t,e){$(e).data("ladda",Ladda.create(e))}))}.bind(this)),this.loadImagesInView()},reloadDecks:function(){return this.decksPagination.current=0,this.decksPagination.html="",this.nextDecksPageXHR&&(this.nextDecksPageXHR.abort(),this.nextDecksPageXHR=null),this.loadNextDecksPage()},loadRemainingDecks:function(){this.remainingDecksState||(this.remainingDecksState="loading",this.decksPagination.html=this.getDeckList(SL.views.users.ShowDeckFilters.PERSONAL_TAB).html(),this.nextDecksPageXHR&&(this.nextDecksPageXHR.abort(),this.nextDecksPageXHR=null),this.decksPagination.current<this.decksPagination.total&&this.loadNextDecksPage().then(function(){this.remainingDecksState="loaded",this.filters.refreshFilters()}.bind(this)))},hasLoadedRemainingDecks:function(){return"loading"===this.remainingDecksState||"loaded"===this.remainingDecksState},loadNextDecksPage:function(){return new Promise(function(t,e){if(this.decksPagination.current<this.decksPagination.total)this.decksPagination.current+=1,this.nextDecksPageXHR=$.ajax({url:SL.endpoints.GET_DECKS_HTML(SLConfig.user.username)+"?page="+this.decksPagination.current,type:"GET",context:this}).done(function(e){this.nextDecksPageXHR=null,this.decksPagination.html+=e,this.loadNextDecksPage().then(t)}).fail(function(){this.nextDecksPageXHR=null,SL.notify("An error occurred while loading decks","negative"),e()});else{var i=this.getDeckList(SL.views.users.ShowDeckFilters.PERSONAL_TAB);i.html(this.decksPagination.html),this.setupDecks(),this.filters.refreshTabs([SL.views.users.ShowDeckFilters.PERSONAL_TAB]),t()}}.bind(this))},reloadTrash:function(){return new Promise(function(t,e){$.ajax({url:SL.endpoints.GET_DECKS_TRASHED_HTML(SLConfig.user.username),type:"GET",context:this}).done(function(e){var i=this.getDeckList(SL.views.users.ShowDeckFilters.TRASH_TAB);i.removeClass("loading"),i.html(e),this.setupDecks(),this.filters.refreshTabs(),t()}).fail(e)}.bind(this))},loadImagesInView:function(){var t=300,e=-t,i=window.innerHeight+t;$(".decks .deck [data-image-url]").each(function(t,n){var s=n.getBoundingClientRect();0===s.width&&0===s.height||s.bottom>e&&s.top<i&&(n.style.backgroundImage='url("'+n.getAttribute("data-image-url")+'")',n.removeAttribute("data-image-url"))}.bind(this))},flash:function(t){t=$(t),clearTimeout(t.data("flash-timeout")),t.removeClass("flash"),SL.util.dom.calculateStyle(t),t.addClass("flash"),t.data("flash-timeout",setTimeout(function(){t.removeClass("flash")},2e3))},flashDecks:function(){this.flash($(".decks"))},scrollIntoView:function(t){var e=t.offset().top-$(window).scrollTop(),i=t.outerHeight(),n=e+i;if(e<0||n>window.innerHeight){var s=t.offset().top;s-=Math.max((window.innerHeight-i)/2,0),$(window).scrollTop(s)}},cloneDeck:function(t,e){t.addClass("hover");var i=t.find(".clone.ladda-button").data("ladda");i&&i.start(),$.ajax({type:"POST",url:SL.endpoints.FORK_DECK(t.data("model").get("id")),context:this}).done(function(){SL.util.callback(e)}).fail(function(){SL.notify(SL.locale.get("GENERIC_ERROR"),"negative"),i&&i.stop(),t.removeClass("hover")})},startDrag:function(){$("html").addClass("dragging-deck"),this.isDragging=!0,this.dragGhosts=$('<div class="deck-ghosts">').appendTo(document.body),this.dragTargets.slice(0,6).each(function(t,e){e=$(e);var i=$('<div class="deck-ghost">').appendTo(this.dragGhosts);i.append(e.find(".sl-deck-thumbnail").clone().removeClass("sl-deck-thumbnail").addClass("deck-ghost-thumbnail")),i.append(e.find(".deck-title").clone())}.bind(this))},stopDrag:function(){$("html").removeClass("dragging-deck"),this.isDragging=!1},animateGhostsIntoTag:function(t){var e=this.dragGhosts,i=t.offset();i.left+=t.width()/2,i.top+=t.height()/2,e.find(".deck-ghost").each(function(t,e){e=$(e);var n=e.offset(),s=i.left-n.left,o=i.top-n.top;e.css({transform:"translate("+s+"px,"+o+"px) scale(0.4)",transition:"all 0.4s cubic-bezier(0.860, 0.000, 0.070, 1.000)","transition-delay":t/15+"s",opacity:0})}),setTimeout(function(){e.remove()},1e3)},animateGhostsIntoVoid:function(){var t=this.dragGhosts;t.find(".deck-ghost").toArray().forEach(function(t,e){$(t).css({transform:"translate(0px, 25px)",transition:"all 0.3s ease","transition-delay":e/25+"s",opacity:0})}),setTimeout(function(){t.remove()},1e3)},toggleSelection:function(t,e){if(t.toggleClass("selected"),this.lastSelection&&e===!0){var i=this.lastSelection.index(),n=t.index();if(Math.abs(i-n)>1){var s;s=n>i?this.lastSelection.nextUntil(t):this.lastSelection.prevUntil(t),s.toggleClass("selected",t.hasClass("selected"))}}else this.lastSelection=t;this.syncSelection()},trashSelection:function(){SL.prompt({anchor:this.toolbar.find(".trash-selection"),title:SL.locale.get("DECK_TRASH_CONFIRM_MULTIPLE"),type:"select",data:[{html:"<h3>Cancel</h3>"},{html:"<h3>Delete</h3>",selected:!0,className:"negative",callback:function(){var t=this.getSelectedDecks();this.clearSelection(),t.toArray().forEach(function(t){this.trashDeck($(t))},this)}.bind(this)}]})},clearSelection:function(){$(".decks .deck").removeClass("selected"),this.lastSelection=null,this.syncSelection()},tagSelection:function(){if(!this.editTagsPrompt){var t=this.tags,e=this.getSelectedDecks().toArray().map(function(t){return $(t).data("model")}),i=t.map(function(i){return{title:i.get("name"),value:i,selected:i.hasItem(e[0]),callback:function(i){i.hasItem(e[0])?t.removeTagFrom(i,e):t.addTagTo(i,e)}}});this.editTagsPrompt=SL.prompt({anchor:this.toolbar.find(".tag-selection"),title:"Edit tags",type:"list",offsetY:-10,confirmLabel:"Done",data:i,optional:!0,listType:"multiselect"}),this.editTagsPrompt.destroyed.add(function(){this.editTagsPrompt=null,this.syncSelection()}.bind(this))}},untagSelection:function(){var t=this.filters.getSelectedTag();t&&(this.tags.removeTagFrom(t,this.getSelectedDecks().toArray().map(function(t){return $(t).data("model")})),SL.notify("Selected decks were untagged"))},syncSelection:function(){this.editTagsPrompt||$(".decks .deck.hidden-via-tag, .decks .deck.hidden-via-search").removeClass("selected");var t=this.getSelectedDecks().length;if(t>0){var e=t+" "+SL.util.string.pluralize("deck","s",t>1)+" selected";this.isDragAndDropEnabled()&&(e+=". Drag decks to tag them."),this.toolbar.find(".description").text(e),this.toolbar.find(".tag-selection").toggle(!this.tags.isEmpty()),this.toolbar.addClass("visible")}else this.lastSelection=null,this.toolbar.removeClass("visible")},syncDeckTags:function(){var t=this.isOwner(),e=this.getDeckList(SL.views.users.ShowDeckFilters.PERSONAL_TAB);e.find(".deck-tags").empty(),$(".deck-filters-tag").each(function(i,n){var s=this.tags.getByID($(n).attr("data-tag-id"));if(s){var o='<div class="deck-tag is-interactive '+(t?"is-editable":"")+'" data-tag-id="'+s.get("id")+'">'+s.get("name");
t&&(o+='<span class="icon i-x deck-tag-remove" data-tooltip="Remove tag"></span>'),o+="</div>",s.getItems().forEach(function(t){e.find('.deck[data-id="'+t+'"] .deck-tags').append(o)})}}.bind(this))},getSelectedDecks:function(){return $(".decks.visible .deck.selected")},getDeckList:function(t){return $('.decks[data-tab-id="'+t+'"]')},refreshUntagButtons:function(){var t=this.getDeckList(SL.views.users.ShowDeckFilters.PERSONAL_TAB),e=this.filters.getSelectedTag();e?(t.addClass("filtered-by-tag"),t.find(".untag").attr("data-tooltip",'Remove from "'+e.get("name")+'"')):t.removeClass("filtered-by-tag")},hasOwnDecks:function(){return this.getDeckList(SL.views.users.ShowDeckFilters.PERSONAL_TAB).find(".deck").length>0},isOwner:function(){return SLConfig.user&&SLConfig.user.id===SL.current_user.get("id")},isSmallScreen:function(){return window.innerWidth<760},isDragAndDropEnabled:function(){return!(this.tags.isEmpty()||this.isSmallScreen()||SL.util.device.IS_PHONE||SL.util.device.IS_TABLET)},trashDeck:function(t){var e=t.data("model");t.addClass("hover");var i=t.find(".trash.ladda-button").data("ladda");i&&i.start(),$.ajax({type:"POST",url:SL.endpoints.TRASH_DECK(e.get("id")),data:{},context:this}).done(function(){this.decksPagination.total-=1,SL.util.anim.collapseListItem(t,function(){i&&i.stop(),t.remove(),this.reloadTrash(),this.tags.removeModelFromAllTags(e)}.bind(this)),SL.notify(SL.locale.get("DECK_TRASH_SUCCESS"))}).fail(function(){SL.notify(SL.locale.get("DECK_TRASH_ERROR"),"negative"),i&&i.stop()}).always(function(){t.removeClass("hover")})},onTagsChanged:function(){this.syncSelection(),this.syncDeckTags()},onTagAssociationChanged:function(){this.syncSelection(),this.syncDeckTags()},onTrashClicked:function(t,e){e.preventDefault(),t.addClass("hover");var i=t.data("model"),n=SL.prompt({anchor:$(e.currentTarget),title:SL.locale.get("DECK_TRASH_CONFIRM",{title:SL.util.escapeHTMLEntities(i.get("title"))}),type:"select",data:[{html:"<h3>Cancel</h3>",callback:function(){t.removeClass("hover")}.bind(this)},{html:"<h3>Delete</h3>",selected:!0,className:"negative",callback:function(){this.trashDeck(t)}.bind(this)}]});n.canceled.add(function(){t.removeClass("hover")}),SL.analytics.track("User.show: Delete deck")},onDestroyClicked:function(t,e){e.preventDefault(),t.addClass("hover");var i=t.data("model"),n=SL.prompt({anchor:$(e.currentTarget),title:SL.locale.get("DECK_DESTROY_CONFIRM",{title:SL.util.escapeHTMLEntities(i.get("title"))}),type:"select",data:[{html:"<h3>Cancel</h3>",callback:function(){t.removeClass("hover")}.bind(this)},{html:"<h3>Delete</h3>",selected:!0,className:"negative",callback:function(){var e=t.find(".destroy.ladda-button").data("ladda");e&&e.start(),$.ajax({type:"DELETE",url:SL.endpoints.DESTROY_DECK(i.get("id")),data:{},context:this}).done(function(){SL.util.anim.collapseListItem(t,function(){e&&e.stop(),t.remove(),this.filters.refreshTabs(),this.filters.refreshTags()}.bind(this)),SL.notify(SL.locale.get("DECK_DESTROY_SUCCESS"))}).fail(function(){SL.notify(SL.locale.get("DECK_DESTROY_ERROR"),"negative"),e&&e.stop()}).always(function(){t.removeClass("hover")})}.bind(this)}]});n.canceled.add(function(){t.removeClass("hover")}),SL.analytics.track("User.show: Destroy deck")},onRecoverClicked:function(t,e){e.preventDefault(),t.addClass("hover");var i=t.data("model"),n=t.find(".recover.ladda-button").data("ladda");n&&n.start(),$.ajax({type:"POST",url:SL.endpoints.RECOVER_DECK(i.get("id")),data:{},context:this}).done(function(){this.decksPagination.total+=1,this.reloadDecks().then(function(){n&&n.stop(),t.remove(),this.filters.refreshTabs(),this.filters.selectTab(SL.views.users.ShowDeckFilters.PERSONAL_TAB);var e=$('.deck[data-id="'+i.get("id")+'"]');e.length&&(this.scrollIntoView(e),e.addClass("recovered"),setTimeout(function(){e.addClass("recovered-visible")},200)),SL.notify(SL.locale.get("DECK_RECOVER_SUCCESS"))}.bind(this),function(){n&&n.stop(),t.remove()}.bind(this))}).fail(function(){SL.notify(SL.locale.get("DECK_RECOVER_ERROR"),"negative"),n&&n.stop()}).always(function(){t.removeClass("hover")}),SL.analytics.track("User.show: Recover deck")},onVisibilityClicked:function(t,e){e.preventDefault(),t.addClass("hover");var i=new SL.components.prompts.DeckVisibility(t.data("model"),{anchor:$(e.currentTarget)});i.show(),i.visibilitySelected.add(function(e,i){var n=t.find("button.visibility").data("ladda");n&&n.start(),i.done(function(e){"string"==typeof e.deck.slug&&t.attr("data-slug",e.deck.slug),"string"==typeof e.deck.visibility&&t.attr("data-visibility",e.deck.visibility)}).always(function(){n&&n.stop(),t.removeClass("hover")})}),i.canceled.add(function(){t.removeClass("hover")}),SL.analytics.track("User.show: Visibility menu opened")},onDeckViewClicked:function(t,e){e.preventDefault(),t.addClass("hover");var i=new SL.components.prompts.DeckView({anchor:$(e.currentTarget),deckModel:t.data("model")});i.show(),i.destroyed.add(function(){t.removeClass("hover")}),SL.analytics.track("User.show: Deck view menu opened")},onSelectionClicked:function(t,e){this.toggleSelection(t,e.shiftKey)},onUntagClicked:function(t,e){e.preventDefault();var i=this.filters.getSelectedTag();i&&(this.tags.removeTagFrom(i,[t.data("model")]),SL.notify("Deck was untagged"))},onShareClicked:function(t,e){e.preventDefault();var i=t.data("model");if("string"!=typeof i.get("user.username")||"string"!=typeof i.get("slug")&&"string"!=typeof i.get("id"))SL.notify(SL.locale.get("GENERIC_ERROR"),"negative");else{i.watch("visibility",function(e){t.attr("data-visibility",e)});SL.popup.open(SL.components.decksharer.DeckSharer,{deck:i})}return!1},onCloneClicked:function(t,e){return e.preventDefault(),this.cloneDeck(t,function(){window.scrollTo(0,0),window.location.reload()}),!1},onForkClicked:function(t,e){return e.preventDefault(),this.cloneDeck(t,function(){window.location=SL.current_user.getProfileURL()}),!1},onDeckTitleClicked:function(t){var e=t.find(".deck-title-value"),i=SL.prompt({anchor:e,title:"Edit deck title",type:"input",confirmLabel:"Save"+SL.util.getKeyboardShortcutName("Enter",{meta:!0,casesensitive:!0,span:!0}),data:{value:e.text(),placeholder:"Deck title...",maxlength:SL.config.DECK_TITLE_MAXLENGTH,width:400,confirmBeforeDiscard:!0}});return i.confirmed.add(function(i){if(i&&""!==i.trim()){e.text(i);var n=t.data("model");n.set("title",i),$.ajax({url:SL.endpoints.UPDATE_DECK(n.get("id")),type:"PUT",context:this,data:{deck:{title:i}}}).fail(function(){SL.notify("An error occured while saving your deck title","negative")})}else SL.notify("Title can't be empty","negative")}.bind(this)),!1},onDeckDescriptionClicked:function(t){var e=t.find(".deck-description-value"),i=SL.prompt({anchor:e,title:"Edit deck description",type:"input",confirmLabel:"Save"+SL.util.getKeyboardShortcutName("Enter",{meta:!0,casesensitive:!0,span:!0}),data:{value:e.text(),placeholder:"A short description of this deck...",multiline:!0,width:400,confirmBeforeDiscard:!0}});return i.confirmed.add(function(i){e.text(i);var n=t.data("model");n.set("description",i),$.ajax({url:SL.endpoints.UPDATE_DECK(n.get("id")),type:"PUT",context:this,data:{deck:{description:i}}}).fail(function(){SL.notify("An error occured while saving your deck description","negative")})}.bind(this)),!1},onDeckClicked:function(t){var e=$(t.target).closest(".deck");if(e&&e.length)if(t.shiftKey||this.getSelectedDecks().length>0)this.toggleSelection(e,t.shiftKey),t.preventDefault();else if($(t.currentTarget).closest(".deck-thumb").length){var i=e.find(".deck-link").get(0);i&&i.click()}},onDeckMouseDown:function(t){var e=$(t.currentTarget);if(e&&e.length&&3!==t.which){var i=e.get(0).getBoundingClientRect();if(this.mouseDownX=t.clientX,this.mouseDownY=t.clientY,this.dragOffsetX=t.clientX-i.x,this.dragOffsetY=t.clientY-i.y,e.hasClass("selected")?this.dragTargets=this.getSelectedDecks():this.dragTargets=e,!this.isDragAndDropEnabled())return;$(document).on("mousemove",this.onDeckMouseMove),$(document).on("mouseup",this.onDeckMouseUp),t.preventDefault()}},onDeckMouseMove:function(t){var e=SL.util.trig.distanceBetween({x:this.mouseDownX,y:this.mouseDownY},{x:t.clientX,y:t.clientY});(e>10||this.isDragging)&&(this.isDragging||this.startDrag(),this.dragGhosts.css({left:t.clientX,top:t.clientY})),t.preventDefault()},onDeckMouseUp:function(t){if($(document).off("mousemove",this.onDeckMouseMove),$(document).off("mouseup",this.onDeckMouseUp),this.isDragging){t.stopPropagation(),t.preventDefault(),this.stopDrag();var e=$(t.target).closest("[data-tag-id]"),i=e.data("tag");i?(this.tags.addTagTo(i,this.dragTargets.toArray().map(function(t){return $(t).data("model")})),this.animateGhostsIntoTag(e),e.addClass("count-changed"),setTimeout(function(){e.removeClass("count-changed")},1e3)):this.animateGhostsIntoVoid(e)}},onWindowScroll:function(){this.loadImagesInView(),this.hasLoadedRemainingDecks()||document.body.scrollHeight-window.scrollY-window.innerHeight<window.innerHeight&&this.loadRemainingDecks()},onDocumentKeyDown:function(t){27===t.keyCode&&this.getSelectedDecks().length>0&&(this.clearSelection(),t.preventDefault())}});
